[Stackless] Figuring out stackless for use in Twisted
Christopher Armstrong
radix at twistedmatrix.com
Wed Jul 30 13:35:43 CEST 2003
On Tue, Jul 29, 2003 at 07:05:49PM +0200, Christian Tismer wrote:
> Christopher Armstrong wrote:
> >The user code itself needs to say when it needs to block (I will
> >provide nice abstractions for this) and I _always_ want the reactor
> >(i.e., main tasklet) to be switched to when the user-tasklet
> >blocks. The reactor will later say when to continue the user-tasklet,
> >when the thing that the user-tasklet was waiting for has occured.
>
> Ok, so you would just make sure that there are only
> two tasklets active: main and the other one.
> You can either grab all tasklets by using the remove()
> method, but it would be much nicer and more in the
> sense of it to use channels for that.
Hmm! I think I realized that I don't really need to do anything
special for this. From an initial state of no tasks::
Reactor calls a user-func. user-func either blocks, or returns.
* If it blocks, it switches back to reactor, because that's the only
other tasklet so far.
- If we start second user-func while back in the reactor from this
point, and it blocks, it will still only switch back to the
reactor, because the other user-func is blocking.
* If it returns, there is only the reactor again.
That is, the only time that I unblock a user-func is going to be
_from_ the reactor tasklet, so it seems that the behavior I want falls
out of this nicely. Two user-func tasklets will never switch between
each other, unless they're talking to the stackless API themselves,
which I don't care about. They can shoot themselves in the foot if
they want :)
Again, thank you for your help and patience. Now I'm going to go
finish this reactor. :-)
--
Twisted | Christopher Armstrong: International Man of Twistery
Radix | Release Manager, Twisted Project
---------+ http://twistedmatrix.com/users/radix.twistd/
More information about the Stackless
mailing list