[Stackless] hi all, can this be implemented ?

zouguangxian zouguangxian at hotmail.com
Thu Sep 30 13:56:29 CEST 2004


hi all,
   i am a newbie in stackless python. but i am attracted by it .now i want to embed stackless python in my c++ program .i hope it can work in this way :
   there is a "event" list,some thread will put  "event" in it. and the script engine thread will pick "event" from this list. pseudocode may like this :

python_generator generator ;   // to save generator object,can i do this ?

while (1) {
   event=pickevent();
   if (event==EVENT1) {
       python.call(func1)
   } else (if event==EVENT2) {
       generator.resum();
       python.call(func2);   
   }
}

...
void func1()
{
   ....
   generator.suspend; //point 1
   ...
}


  yes,when i receive EVENT1,the func1 was called,and after some statement,i hope it will be paused at point 1, but will block the main loop. when EVENT2 was received in main loop, then resume the func1,let it continue run from point 1. can i do in this way ? 
  maybe i should explain more . i want to embed stackless python in a game as scripting engine. maybe NPC will talk to player and wait the player to click on some button , I hope the tasklet (i think it is ,can i think so ?) will be  paused before the player click the button and will not block main loop. once the player click on some button , the tasklet will continue at the paused point .
  can you give me some advice ? do i need callback instead of tasklet(micro-thread) ?
  thanks!
-weck
-------------- next part --------------
_______________________________________________
Stackless mailing list
Stackless at stackless.com
http://www.stackless.com/mailman/listinfo/stackless


More information about the Stackless mailing list