Hi Kristjan:

Message: 4
Date: Fri, 9 Sep 2011 18:37:27 +0000
From: Kristj?n Valur J?nsson <[email protected]>
To: The Stackless Python Mailing List <[email protected]>
Subject: Re: [Stackless] tasklets on threads
Message-ID:
    <efe3877620384242a686d52278b7ccd3181...@rkv-it-exch104.ccp.ad.local>
Content-Type: text/plain; charset="iso-8859-1"

>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.

I haven't used tasklets with other threads for a while. I figure the motivation 
to spawn threads is to isolate operations that are CPU intensive or potentially 
long blocking. Here is a suggestion, inspired in part by the Go language. 
Create new stackless function that would a create secondary schedulers that run 
in new thread. Abstract away thread creation. Secondary schedulers would work 
like the main scheduler with one exception: if there is at least one tasklet is 
blocked on a channel shared by another tasklet/scheduler, the secondary 
scheduler (and with it the thread) will not terminate. 

Cheers,
Andrew
_______________________________________________
Stackless mailing list
[email protected]
http://www.stackless.com/mailman/listinfo/stackless

Reply via email to