[Stackless] integrate stackless with other event driven framework: merge two main loop

Jimsfba at aol.com Jimsfba at aol.com
Sat Oct 14 08:16:59 CEST 2006


Hi, I think it might be a common question about integrating stackless and  
other event driven framework. In most cases, the other event driven framework  
uses main loop and listening on select() or poll() calls like this:
 
while ( forever  ) {
 
    add event queue 1 unix domain socket to file descriptor  sets
add event queue 2 unix domain socket to file  descriptor sets
... 
add tcp  connection 1 to file descriptor sets
add tcp connection 2  to file descriptor sets

select(  file descriptor sets 1 ) ; // block here and wait for any event (fd 
status)  change
 
    check which file descriptor has been changed and process  that event
...
}
 
I have a C++ event driven main loop framework that embedded the stackless  
framework. 
The only way I can make these two framework work together is:  switching 
between two frameworks in a fix time range.
 
1. timeout the select() call in my C++ main loop every few hundreds  
milliseconds, 
2. give a few hundress millisecond for stackless code to  run:
watchdogHandle =  handle<>(allow_null(PyStackless_RunWatchdog(1000)));
3. go back to the  C++ main loop and block on select() again
 
This way works but not so elegant. It might be idle and waste a few hundred  
millisecond per loop in one framework while the other framework has work 
waiting  for it to do.
 
I am thinking a "perfect" model will be ...
 
If stackless internally is also blocking on a select( fdset2 ) call, we can  
add a stackless API to export that file descriptor set (fdset2).
Then we can  merge two select() calls of two main loops into a single select( 
fdset1+ fdset2  ) call. We can then listen to all events in one blocking 
select call.
 
I would like to hear any suggestion / experience in this area. Thanks a  lot.
 
- Jim
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.stackless.com/pipermail/stackless/attachments/20061014/6c03e9ba/attachment.htm>
-------------- next part --------------
An embedded message was scrubbed...
From: Jimsfba at aol.com
Subject: pause execusion of tasklet using remove()
Date: Thu, 12 Oct 2006 20:02:28 EDT
Size: 5271
URL: <http://www.stackless.com/pipermail/stackless/attachments/20061014/6c03e9ba/attachment.eml>
-------------- next part --------------
_______________________________________________
Stackless mailing list
Stackless at stackless.com
http://www.stackless.com/mailman/listinfo/stackless


More information about the Stackless mailing list