[Stackless] Queues

Richard richard at ccpgames.com
Tue Apr 4 09:49:12 CEST 2006


I suspect you could get rid of the uselesstasklet by setting the 'preference' value
on the channel to some value, 0 if I recall.  But you might have to read the C
source to know for sure.
 
If someone sorts out how it works and sends me a more explanatory doc
string, I can check it in.  Same for any of the other doc strings you may feel
are lacking.
 
I don't think you need permission to change anything in the wiki.  If anyone
wants any pages added, send me the name and I'll do it myself as I don't
have any other solution for that problem.
 
Richard.

-----Original Message-----
From: stackless-bounces at stackless.com [mailto:stackless-bounces at stackless.com]On Behalf Of Benjamin Buco
Sent: 04 April 2006 01:35
To: stackless at stackless.com
Subject: [Stackless] Queues


This is an implementation  for what amounts to a queue or buffered channel.  Any suggestions, advice, criticism before I post this to the wiki would be appreciated.  Its probably not the cleanest solution but at least it's pretty.  Also anyone have any objections to me restoring the link to the channels page to the main stackless page?
 
 
import stackless
class Queue(stackless.channel):
    def uselesstasklet(self,value):
        return stackless.channel.send(self, value)
    def send(self, value, wait=False):
        useless = stackless.tasklet(self.uselesstasklet)(value)
        stackless.schedule(useless)
        return None
        
def testQueue():
    print
    print "testQueue"
    print "--------------------"
    def recv(ch, name):
        print "Started recv<%s>" % (name,)
        print "recv<%s>: %r" % (name, ch.receive())
    ch = Queue()
    # Queues are nonblocking on sends when there are no receivers
    ch.send("Primary Entry")
    ch.send("Secondary Entry")
    for name in "ABCD":
        task = stackless.tasklet(recv)(ch, name)
        task.run()
    ch.send("Third Entry")
    ch.send("Fourth Entry")
    print
testQueue()
 
Thanks guys.
 
Benjamin Buco
MCSE:Security
IT Instructor
TechSkills Cincinnati



  _____  

Blab-away for as little as 1¢/min. Make PC-to-Phone  <http://us.rd.yahoo.com/mail_us/taglines/postman2/*http://us.rd.yahoo.com/evt=39663/*http://voice.yahoo.com> Calls using Yahoo! Messenger with Voice.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.stackless.com/pipermail/stackless/attachments/20060404/dea15852/attachment.htm>
-------------- next part --------------
_______________________________________________
Stackless mailing list
Stackless at stackless.com
http://www.stackless.com/mailman/listinfo/stackless


More information about the Stackless mailing list