Wiki Page Content

Differences between revisions 2 and 3
Revision 2 as of 2013-08-15 05:29:09
Size: 1544
Editor: andred
Comment: Whops, function params in header
Revision 3 as of 2013-08-19 01:15:33
Size: 1547
Editor: RyanGordon
Comment: Updated with Philipp's changes from old server
Deletions are marked like this. Additions are marked like this.
Line 14: Line 14:
int SDL_LockMutex(SDL_mutex * mutex) int SDL_TryLockMutex(SDL_mutex * mutex)

DRAFT

SDL_TryLockMutex

Use this function to try to lock a mutex without blocking.

Syntax

int SDL_TryLockMutex(SDL_mutex * mutex)

Function Parameters

mutex

the mutex to try to lock

Return Value

Returns return 0, SDL_MUTEX_TIMEDOUT, or -1 on error; call SDL_GetError() for more information.

Code Examples

int status;
SDL_mutex *mutex;

mutex = SDL_CreateMutex();
if (!mutex) {
  fprintf(stderr, "Couldn't create mutex\n");
  return;
}

status = SDL_TryLockMutex(mutex);

if (status == 0) {
  printf("Locked mutex\n");
  SDL_UnlockMutex(mutex);
} else if (status == SDL_MUTEX_TIMEDOUT) {
  /* Mutex not available for locking right now */
} else {
  fprintf(stderr, "Couldn't lock mutex\n");
}

SDL_DestroyMutex(mutex)

Remarks

You can add useful comments here


CategoryAPI, CategoryHeader


CategoryMutex

None: SDL_TryLockMutex (last edited 2015-04-26 19:00:12 by PhilippWiesemann)

(Page Info.)
Feedback
Please include your contact information if you'd like to receive a reply.
Submit