[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Help-smalltalk] Dispatching blocks to another context and break for
Re: [Help-smalltalk] Dispatching blocks to another context and break for collections
Wed, 29 Jun 2011 08:11:05 +0200
Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:220.127.116.11) 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].
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:
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].
orig remove: each ]
One thing I can think of is something like this...
[copy isEmpty not and: [copy first isJounEnough]] whileTrue: .
This one definitely has better performance.