mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-05-31 08:57:40 +00:00
thread: Locking mutexes and rwlocks are now void functions.
Almost nothing checks these return values, and there's no reason a valid lock should fail to operate. The cases where a lock isn't valid (it's a bogus pointer, it was previously destroyed, a thread is unlocking a lock it doesn't own, etc) are undefined behavior and always were, and should be treated as an application bug. Reference Issue #8096.
This commit is contained in:
parent
082ef41566
commit
899eb0d042
21 changed files with 496 additions and 746 deletions
|
@ -80,17 +80,12 @@ Run(void *data)
|
|||
SDL_Log("Thread %lu: starting up", SDL_ThreadID());
|
||||
while (!SDL_AtomicGet(&doterminate)) {
|
||||
SDL_Log("Thread %lu: ready to work\n", SDL_ThreadID());
|
||||
if (SDL_LockMutex(mutex) < 0) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't lock mutex: %s", SDL_GetError());
|
||||
exit(1);
|
||||
}
|
||||
SDL_LockMutex(mutex);
|
||||
SDL_Log("Thread %lu: start work!\n", SDL_ThreadID());
|
||||
SDL_Delay(1 * worktime);
|
||||
SDL_Log("Thread %lu: work done!\n", SDL_ThreadID());
|
||||
if (SDL_UnlockMutex(mutex) < 0) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't unlock mutex: %s", SDL_GetError());
|
||||
exit(1);
|
||||
}
|
||||
SDL_UnlockMutex(mutex);
|
||||
|
||||
/* If this sleep isn't done, then threads may starve */
|
||||
SDL_Delay(10);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue