SDL threading / C++ libraries

The SDL threads documentation states, among other things:

“Don’t use any library functions in separate threads”

Does this mean it’s inherently unsafe to use Standard C++ library
containers (std::vector, etc.) in worker threads? Even if I protect
them with mutexes? Are there specific platforms where this would be a
problem? (I can’t imagine it being a problem on Win32 but I don’t have
enough experience on other platforms to know whether their C++ libraries
are thread safe–in particular, I’d like my program to be able to run on
Linux and possibly OS X in addition to Win32.)

I do realize that some C library functions that use static data (such as
strtok) are inherently unsafe in multithreaded programs, but I’d rather
not have to re-invent the wheel when it comes to STL containers and
algorithms.

IT depends on what you call thread safe, and what STL you’re using.
SGI’s STL (which Linux (at least, every version of Linux I’ve used)
uses) is thread safe. The specifics of what YOU must mutex can be found
here:

http://www.sgi.com/tech/stl/thread_safety.html

Which of course doesn’t apply to MS’s implementation of the STL. After
using STL extensively on Linux and Win32 I can safely say you’re better
off in the long run to switch to SGI’s STL anyway.

Anyway.
Blah.On Sat, 2003-04-19 at 17:43, Jeremy Stanley wrote:

The SDL threads documentation states, among other things:

“Don’t use any library functions in separate threads”

Does this mean it’s inherently unsafe to use Standard C++ library
containers (std::vector, etc.) in worker threads? Even if I protect
them with mutexes? Are there specific platforms where this would be a
problem? (I can’t imagine it being a problem on Win32 but I don’t have
enough experience on other platforms to know whether their C++ libraries
are thread safe–in particular, I’d like my program to be able to run on
Linux and possibly OS X in addition to Win32.)

I do realize that some C library functions that use static data (such as
strtok) are inherently unsafe in multithreaded programs, but I’d rather
not have to re-invent the wheel when it comes to STL containers and
algorithms.


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl


Jimmy <@Jimmy>
Jimmy’s World
-------------- next part --------------
A non-text attachment was scrubbed…
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20030419/9c1bca69/attachment.pgp