help-smalltalk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-smalltalk] Proxy learning exercise


From: Stephen
Subject: Re: [Help-smalltalk] Proxy learning exercise
Date: Tue, 12 Aug 2008 07:34:10 +1200
User-agent: Thunderbird 2.0.0.16 (Macintosh/20080707)

Paolo Bonzini wrote:

> You can use two processes.
>
> p1 := [
>     source ensureReadable.
>     source isPeerAlive ifFalse: [ p1 terminate. p2 terminate ].
>     dest nextPutAllFlush: source nextHunk ] newProcess.
> p2 := [
>     dest ensureReadable.
>     dest isPeerAlive ifFalse: [ p1 terminate. p2 terminate ].
>     source nextPutAllFlush: dest nextHunk ] newProcess.
>
> p1 resume.
> p2 resume
>
>
> In 3.0c there is no #nextHunk, so you can use StreamSocket to remove the
> write buffering and do
>
> p1 := [
>     source ensureReadable.
>     source isPeerAlive ifFalse: [ p1 terminate. p2 terminate ].
>     source nextAvailablePutAllOn: dest ] newProcess.
> p2 := [
>     dest ensureReadable.
>     dest isPeerAlive ifFalse: [ p1 terminate. p2 terminate ].
>     dest nextAvailablePutAllOn: source ] newProcess.
>
> p1 resume.
> p2 resume
>
>
> This has better performance because it does not do unnecessary copies
> and creation of objects.
>
> Paolo
>

Thank you Paolo.

I've found this solution extremely helpful. Thanks for putting the "new" solution in as well - that was going to be the next part of the exercise!

Stephen




reply via email to

[Prev in Thread] Current Thread [Next in Thread]