WinRT: made testthread to use SDL_Log, not printf or fprintf, for MSVC++ logging
This commit is contained in:
parent
076650c286
commit
bc67a6617f
1 changed files with 8 additions and 8 deletions
|
@ -32,20 +32,20 @@ quit(int rc)
|
||||||
int SDLCALL
|
int SDLCALL
|
||||||
ThreadFunc(void *data)
|
ThreadFunc(void *data)
|
||||||
{
|
{
|
||||||
printf("Started thread %s: My thread id is %lu\n",
|
SDL_Log("Started thread %s: My thread id is %lu\n",
|
||||||
(char *) data, SDL_ThreadID());
|
(char *) data, SDL_ThreadID());
|
||||||
while (alive) {
|
while (alive) {
|
||||||
printf("Thread '%s' is alive!\n", (char *) data);
|
SDL_Log("Thread '%s' is alive!\n", (char *) data);
|
||||||
SDL_Delay(1 * 1000);
|
SDL_Delay(1 * 1000);
|
||||||
}
|
}
|
||||||
printf("Thread '%s' exiting!\n", (char *) data);
|
SDL_Log("Thread '%s' exiting!\n", (char *) data);
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
killed(int sig)
|
killed(int sig)
|
||||||
{
|
{
|
||||||
printf("Killed with SIGTERM, waiting 5 seconds to exit\n");
|
SDL_Log("Killed with SIGTERM, waiting 5 seconds to exit\n");
|
||||||
SDL_Delay(5 * 1000);
|
SDL_Delay(5 * 1000);
|
||||||
alive = 0;
|
alive = 0;
|
||||||
quit(0);
|
quit(0);
|
||||||
|
@ -58,18 +58,18 @@ main(int argc, char *argv[])
|
||||||
|
|
||||||
/* Load the SDL library */
|
/* Load the SDL library */
|
||||||
if (SDL_Init(0) < 0) {
|
if (SDL_Init(0) < 0) {
|
||||||
fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError());
|
SDL_LogError(SDL_LOG_CATEGORY_ERROR, "Couldn't initialize SDL: %s\n", SDL_GetError());
|
||||||
return (1);
|
return (1);
|
||||||
}
|
}
|
||||||
|
|
||||||
alive = 1;
|
alive = 1;
|
||||||
thread = SDL_CreateThread(ThreadFunc, "One", "#1");
|
thread = SDL_CreateThread(ThreadFunc, "One", "#1");
|
||||||
if (thread == NULL) {
|
if (thread == NULL) {
|
||||||
fprintf(stderr, "Couldn't create thread: %s\n", SDL_GetError());
|
SDL_LogError(SDL_LOG_CATEGORY_ERROR, "Couldn't create thread: %s\n", SDL_GetError());
|
||||||
quit(1);
|
quit(1);
|
||||||
}
|
}
|
||||||
SDL_Delay(5 * 1000);
|
SDL_Delay(5 * 1000);
|
||||||
printf("Waiting for thread #1\n");
|
SDL_Log("Waiting for thread #1\n");
|
||||||
alive = 0;
|
alive = 0;
|
||||||
SDL_WaitThread(thread, NULL);
|
SDL_WaitThread(thread, NULL);
|
||||||
|
|
||||||
|
@ -77,7 +77,7 @@ main(int argc, char *argv[])
|
||||||
signal(SIGTERM, killed);
|
signal(SIGTERM, killed);
|
||||||
thread = SDL_CreateThread(ThreadFunc, "Two", "#2");
|
thread = SDL_CreateThread(ThreadFunc, "Two", "#2");
|
||||||
if (thread == NULL) {
|
if (thread == NULL) {
|
||||||
fprintf(stderr, "Couldn't create thread: %s\n", SDL_GetError());
|
SDL_LogError(SDL_LOG_CATEGORY_ERROR, "Couldn't create thread: %s\n", SDL_GetError());
|
||||||
quit(1);
|
quit(1);
|
||||||
}
|
}
|
||||||
raise(SIGTERM);
|
raise(SIGTERM);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue