[Stackless] Stop tasklet when a certain other set of tasklets is finished

Richard Tew richard.m.tew at gmail.com
Tue Nov 2 05:07:26 CET 2010

On Tue, Nov 2, 2010 at 7:48 AM, Heinrich Schmetterling
<heinrich.schmetterling at gmail.com> wrote:
> I have an architecture where worker tasklets are repeatedly creating other
> worker tasklets when traversing a tree structure. I want a special tasklet
> to be runnable while the set of worker tasklets is not empty. Is there a way
> to do this using some feature of stackless without having to explicitly keep
> track of how many runnable worker tasklets exist at any given time? For
> example, I'm trying to avoid keeping a global counter somewhere and
> observing that counter in the special tasklet every time it regains control.

Add all worker tasklets to a weakref set, and when the special tasklet
wakes to an empty weakref set, block it on a channel.  Then when
creating a worker tasklet and adding it to the set, if the special
tasklet is blocked on a channel, wake it up to continue being

Something like that.  This is something you would do in "user space",
in any case :-)


More information about the Stackless mailing list