mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-06-04 19:07:40 +00:00
Renamed atomic functions to match SDL 3.0 naming convention
This will also allow us to cleanly add atomic operations for other types in the future.
This commit is contained in:
parent
f3e419596b
commit
8d223b3037
64 changed files with 496 additions and 472 deletions
|
@ -62,7 +62,7 @@ ThreadFunc(void *data)
|
|||
SDL_SetTLS(&tls, "baby thread", NULL);
|
||||
SDL_Log("Started thread %s: My thread id is %" SDL_PRIu64 ", thread data = %s\n",
|
||||
(char *)data, SDL_GetCurrentThreadID(), (const char *)SDL_GetTLS(&tls));
|
||||
while (SDL_AtomicGet(&alive)) {
|
||||
while (SDL_GetAtomicInt(&alive)) {
|
||||
SDL_Log("Thread '%s' is alive!\n", (char *)data);
|
||||
|
||||
if (testprio) {
|
||||
|
@ -83,7 +83,7 @@ killed(int sig)
|
|||
{
|
||||
SDL_Log("Killed with SIGTERM, waiting 5 seconds to exit\n");
|
||||
SDL_Delay(5 * 1000);
|
||||
SDL_AtomicSet(&alive, 0);
|
||||
SDL_SetAtomicInt(&alive, 0);
|
||||
SDL_WaitThread(thread, NULL);
|
||||
quit(0);
|
||||
}
|
||||
|
@ -133,7 +133,7 @@ int main(int argc, char *argv[])
|
|||
SDL_SetTLS(&tls, "main thread", NULL);
|
||||
SDL_Log("Main thread data initially: %s\n", (const char *)SDL_GetTLS(&tls));
|
||||
|
||||
SDL_AtomicSet(&alive, 1);
|
||||
SDL_SetAtomicInt(&alive, 1);
|
||||
thread = SDL_CreateThread(ThreadFunc, "One", "#1");
|
||||
if (!thread) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create thread: %s\n", SDL_GetError());
|
||||
|
@ -141,12 +141,12 @@ int main(int argc, char *argv[])
|
|||
}
|
||||
SDL_Delay(5 * 1000);
|
||||
SDL_Log("Waiting for thread #1\n");
|
||||
SDL_AtomicSet(&alive, 0);
|
||||
SDL_SetAtomicInt(&alive, 0);
|
||||
SDL_WaitThread(thread, NULL);
|
||||
|
||||
SDL_Log("Main thread data finally: %s\n", (const char *)SDL_GetTLS(&tls));
|
||||
|
||||
SDL_AtomicSet(&alive, 1);
|
||||
SDL_SetAtomicInt(&alive, 1);
|
||||
(void)signal(SIGTERM, killed);
|
||||
thread = SDL_CreateThread(ThreadFunc, "Two", "#2");
|
||||
if (!thread) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue