[Stackless] tasklets on threads
senn at maya.com
Fri Sep 9 21:03:48 CEST 2011
On Sep 9, 2011, at 2:37 PM, Kristján Valur Jónsson wrote:
> Hm, you are probably right. Maybe Im just fussing about. I'll have to go and investigate some more.
> Btw, all of this comes from a desire to hand off jobs to tasklets on other threads. What I am aiming to add is a way to figure out if that thread is "blocked", i.e. that it is waiting for stuff to do. Since tasklets are associated with threads, my current idea is to add an attribute to tasklets, something like tasklet.idle, which would be True if that tasklet's thread is idle. A pool of such threads could then be maintained and a job can be handed off to one of them, depending on their idlestate, using channels. No need to mess around with locks and condition variables and whatnot.
Hm. That doesn't sound possible (without causing some race condition to be present) -- unless you mean, by "idle", something more like "might still be idle by the time I get around to sending it a message"... that seems of limited utility for basic load balancing, or in a 1-producer-N-consumer situation...
More information about the Stackless