To thread or not to thread

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

I’m writing a library using SDL, and I want to set it up to be thread
safe when threads are enabled in SDL (e.g. using mutexes to lock
structures), but still to work when threads are not enabled.

I figure one solution is a run time check for the error message “SDL not
configured with thread support” in SDL_CreateMutex, but that is a kludge
at best.

So is there any preprocessor variable accessible from outside SDL which
indicates whether or not thread support is available?

Chris E.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFBBqzCRgD2xPOqY+URAs0eAJ9loD+fssUuwEFQlo079y281N9YEACfSX/e
vvq0pGshvrB90mmfNyMhGw0=
=DQCg
-----END PGP SIGNATURE-----

Since no one has offered a better solution, you could let the
programmer specify whether or not he’s using threads in some sort of
initialization routine.On Jul 27, 2004, at 3:28 PM, Chris E. wrote:

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

I’m writing a library using SDL, and I want to set it up to be thread
safe when threads are enabled in SDL (e.g. using mutexes to lock
structures), but still to work when threads are not enabled.

I figure one solution is a run time check for the error message “SDL
not
configured with thread support” in SDL_CreateMutex, but that is a
kludge
at best.

So is there any preprocessor variable accessible from outside SDL which
indicates whether or not thread support is available?

Chris E.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFBBqzCRgD2xPOqY+URAs0eAJ9loD+fssUuwEFQlo079y281N9YEACfSX/e
vvq0pGshvrB90mmfNyMhGw0=
=DQCg
-----END PGP SIGNATURE-----


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

  • Donny Viszneki

Donny Viszneki wrote:

Since no one has offered a better solution, you could let the programmer
specify whether or not he’s using threads in some sort of initialization
routine.

I’m thinking of just ignoring the “SDL not configured with thread
support” error.

An alternative way to thread-safe this particular function would be to
have the SDL event queue locked for longer than a single
SDL_PeepEvents() call. Does anyone know a way to do that?

Chris E.
-------------- next part --------------
A non-text attachment was scrubbed…
Name: signature.asc
Type: application/pgp-signature
Size: 252 bytes
Desc: OpenPGP digital signature
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20040728/d7f5e5fd/attachment.pgp

What does your library do?On Jul 28, 2004, at 8:26 AM, Chris E. wrote:

Donny Viszneki wrote:

Since no one has offered a better solution, you could let the
programmer
specify whether or not he’s using threads in some sort of
initialization
routine.

I’m thinking of just ignoring the “SDL not configured with thread
support” error.

An alternative way to thread-safe this particular function would be to
have the SDL event queue locked for longer than a single
SDL_PeepEvents() call. Does anyone know a way to do that?

Chris E.


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

  • Donny Viszneki

Donny Viszneki wrote:

What does your library do?

It has a C++ wrapper for SDL, SDL_image, SDL_mixer, SDL_net and
FreeType2, and also some GUI functionality.

Chris E.
-------------- next part --------------
A non-text attachment was scrubbed…
Name: signature.asc
Type: application/pgp-signature
Size: 252 bytes
Desc: OpenPGP digital signature
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20040728/845dc496/attachment.pgp