help-smalltalk
[Top][All Lists]
Advanced

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

Re: [Help-smalltalk] Dispatching blocks to another context and break for


From: Paolo Bonzini
Subject: Re: [Help-smalltalk] Dispatching blocks to another context and break for collections
Date: Wed, 29 Jun 2011 08:11:05 +0200
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.17) Gecko/20110428 Fedora/3.1.10-1.fc15 Mnenhy/0.8.3 Thunderbird/3.1.10

On 06/28/2011 07:49 PM, Holger Hans Peter Freyther wrote:
copy do: [:each |
        each isTooOld ifTrue: [^true].
        each doStuff
        orig remove: each
].


Now I started to dispatch the block to another process (to avoid some locking
issues right now..) but obviously I get a BadReturn when invoking it in
another Context. Is there something like a 'break' for Iterable>>do:? is there
any other selector to help me?

There's of course exception handling, but that's pretty heavyweight. I've seen people use this:

Iterable>>withBreakDo: aBlock
    break := [ :value | ^self].
    self do: [ :each | aBlock value: each value: break].

so that you can do

copy do: [ :each |
    each isTooOld ifTrue: [break value: true].
    each doStuff
    orig remove: each ]

One thing I can think of is something like this...

[copy isEmpty not and: [copy first isJounEnough]] whileTrue: [].

anything else?

This one definitely has better performance.

Paolo



reply via email to

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