[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Thread safety in games

Quoting Dan Kegel (dank@alumni.caltech.edu):

> It's very easy to shoot yourself in the foot with
> threads, though.  The only really safe way to use multiple
> threads is to let the various threads communicate
> only in a very simple, well defined manner, usually
> through a queue.  (Anything more complicated leads
> to mysterious deadlocks, in my meager experience,
> unless you're Linus Torvalds.  And even then, sometimes.)

Yup, this is also the way ClanLib's internal threads communicate. The
external interface to ClanLib however is single threaded - and I believe it
should stay that way. All display, sound and network threads should belong
to the libs used by the game.
Only when speaking of network games, it may be usefull to run the server code
in an other thread, so other players (with faster computers) don't get the
same frame rate...

Magnus Norddahl
Memeber of the ClanLib group