From: Jan E. <ch...@in...> - 2000-10-09 13:51:01
|
On Sun, 8 Oct 2000, Ray Kelm wrote: >Maybe I didn't explain that well enough. The C code that performs the >blocking functions in python *releases* the lock, so that other threads >can run. One thread doesn't block other threads, unless the C code that >contains a blocking call does not release the lock, which is what pysdl >does right now. It can be fixed. I had a look at the functions in pysdl, and I get what you mean. I also looked at the docs for PyEval_SaveThread/RestoreThread and I start to understand what it is about. I was curious as to wether I could make it work myself, so I added the necessary two functions to the pysdl function sdl_events_wait(), and it kind of worked... :-) It didn't block out my other two threads anymore, but they also didn't block at all, i.e. my thread that was supposed to perform a blocking read() on a socket returned immediately. Well, no harm done, I will try another approach without threads. Thinking about it, polling is ok, as a game is allowed to hog anything it want, including the CPU. Nobody should complain about a game taking too much CPU. Polling it is, then. :-) I added the missing PyMem_Free to sdl_events_poll() and which seems to work quite ok and not leak memory like a pig... Thanks a lot for the patient help in making me understand things! Btw, the current sdlmodule.[c|h] are quite hard to maintain. The header-file is even a lot longer than most of my .c or .cpp files! The discussed split would come in quite handy. Maybe splits into at least separate files for events, video, sound, input, cdrom etc? Regards, Chakie --------------------+-------------------------------------------------------- Jan 'Chakie' Ekholm | Balrog New Media http://www.balrog.fi/ Linux Inside | I'm the blue screen of death, nobody hears your screams |