Other ways to support Sylphis3D...
Hi, I've been following the opensourcing of you engine and the
stackless article you wrote some time ago was my start into stackless
python.
Now I participate in stackless mailing list and want to provide ideas
and solutions to he community.
Looking thru your code, i depared with mthread.py which seems as a
stackless wrapper for all tasklet creation and management. The part
that grabbed my attention is the sleep() call. I've been searching for
a way to create a lightweight method of managing sleeping tasklets but
found none yet.
How do you manage the sleeping tasklets after the enter the sleepersCh list? What monitors this list and wakes the sleeping tasklet. I found that the function that awakes them is in mthread.py but what does the processing and calls the wake method? Is there any C code doing this?
Another question is about the stackless loop, is it running in a thread and the other components like the 3D engine and etc on other threads or do you have everything in one thread and tasklets assigned for them all?
Thank you very much,
Carlos Eduardo
Sylphis3D uses two sleep
Sylphis3D uses two sleep wait queues. The
sleepersand thesleepersRealtime. When a thread needs to sleep its put on one of those lists, based on whether it sleeps on real time, or game world time. Each list contains threads along with the time the threads need to wake up. In theupdate()function that is called every frame, we check if any threads need to wake up and we wake them. This is all implemented in Python, but one could reimplement it in C. However its quite fast in Python since I use thebisectmodule to keep the queues sorted. In Sylphis3D all are run in a single thread. There is no multiprocessor support yet. However you can use a second thread that will wake the sleeping tasklets, by making it sleep until the time the first tasklet in the queue needs to be waken.