Fail on mutex instead of wait

Is there a way to get the SDL_LockMutex() call to fail instead
of waiting for a lock?

Is there a way to get the SDL_LockMutex() call to fail instead
of waiting for a lock?

No, but you could use a semaphore with an initial count of 1 instead.

-Sam Lantinga, Senior Software Engineer, Blizzard Entertainment

Is there a way to get the SDL_LockMutex() call to fail instead
of waiting for a lock?

No, but you could use a semaphore with an initial count of 1 instead.

-Sam Lantinga, Senior Software Engineer, Blizzard Entertainment

Or you could use SDL_SemTryWait wait on a semaphore.

Just a word of caution to the original poster, checking leads to busy
waiting and one of the whole points of using mutexes and semaphores is
to avoid busy waiting. In other words, if you think you need to check a
mutex to see if it is locked then there is a better than 50% chance that
your design is wrong.

	Bob PendletonOn Thu, 2006-04-20 at 09:43 -0700, Sam Lantinga wrote:

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


±-------------------------------------+

Yes, I took one look at the design and saw that it was grotesque.

It has been replaced with one that doesn’t need any mutexes
at all!

Thanks anyway.