On Wed, Dec 15, 2010 at 1:51 AM, Ben Noordhuis <i...@bnoordhuis.nl> wrote: > On Tue, Dec 14, 2010 at 23:45, Michael Menegakis <arx...@gmail.com> wrote: >> It's not easy to make something on ioquake3 thread safe. e.g. Whenever >> i want to print something from it I completely avoid Com_Printf (since >> it's massively thread unsafe recursively) and only write on a mutex >> protected 'to print' variable. > > Pro tip: have your worker thread put strings in a mutex-protected > circular buffer or linked list and let the main thread print them. > > Ideally, worker threads only process data and leave it to the main > thread to interpret the results (translation vs printing in this > case).
I currently have it on a single char* variable. Surprisingly, this 'single element buffer' doesn't fill up easily. Then again, computers are fast:) (Of course, I would replace it with an array of say 4, if it deems necessary). _______________________________________________ ioquake3 mailing list ioquake3@lists.ioquake.org http://lists.ioquake.org/listinfo.cgi/ioquake3-ioquake.org By sending this message I agree to love ioquake3 and libsdl.