From: Jan E. <ch...@in...> - 2000-10-07 09:12:05
|
On Fri, 6 Oct 2000, Pete Shinners wrote: >hi jan. most of the things you're asking about largely depend >on how the SDL library handles things. on many platforms (perhaps >all) the event handling is thread safe. in fact on some (like X11) >the event handling is already handled in a separate thread. Ok, sounds fine. >as far as handling threads, you'll find pysdl does not support >the SDL threading routines. this is because python already >comes with great crossplatform threading. (also with it's own >semaphores/mutexes/locks). your best bet is to peek at the >'Threading' module ...which was exactly the page I had in front of me. I have no problems using threads, just the general thread-safeness of the system is interesting. And problems with that tend to be hard to spot, very hard to debug and otherwise just a PITA. >because the event objects are written as C extensions, it is >not easy to modify them much from the python side. your idea >for a global user-data queue sounds like the best idea for now. Yep, it should also be quite simple, as there are ready synchronized queues etc. >just a note here, you might have good results with the 'select' >module. this works on windows and unix. it allows you to do >asynchronous networking on a single thread. it even works well >with multiple sockets. i've never looked into it too far, but >i've heard good things about it. anyways if the threading gets >too tricky, it might be a good alternative. I don't want to use that one. I'm more confident with splitting up my game in as many logical modules as possible, and threads are a good idea of a logical module in my world. Sure, they add complexity and reduce speed (maybe), but will end up making my main event loop simpler. I can then just sit an wait for some event to occur (user does something, packet arrives etc). >good luck with everything It will be needed. I'll return and cry when all fails... :-) Btw, anyone here interested in strategic games with too much time on their hands and an urge to help with some design issues (or coding too, of course)? --------------------+-------------------------------------------------------- Jan 'Chakie' Ekholm | Balrog New Media http://www.balrog.fi/ Linux Inside | I'm the blue screen of death, nobody hears your screams |