|
Size: 1156
Comment: update content - pointers, structs
|
Size: 2123
Comment: Added sample code
|
| Deletions are marked like this. | Additions are marked like this. |
| Line 3: | Line 3: |
| ||<tablewidth="100%" style="color: #FF0000;" :> DRAFT|| | ||<tablewidth="100%"style="color: rgb(255, 0, 0); text-align: center;">DRAFT || |
| Line 15: | Line 16: |
| == Function Parameters == ||'''thread''' ||^the thread to wait for^ || ||'''status''' ||^the pointer to receive the return code???^; see [[#Remarks|Remarks]] for details || |
|
| Line 16: | Line 20: |
| == Function Parameters == ||'''thread'''||^the thread to wait for^|| ||'''status'''||^the pointer to receive the return code???^; see [[#Remarks|Remarks]] for details|| |
|
| Line 24: | Line 25: |
| You can add your code example here | Toggle line numbers #include <stdio.h> #include <SDL_thread.h> #include <SDL_timer.h> int TestThread( void *ptr ); int main(int argc, char *argv[]) { SDL_Thread *thread; int threadReturnValue; printf("\nSimple SDL_CreateThread test:"); // Simply create a thread thread = SDL_CreateThread( TestThread, (void *)NULL); if( NULL == thread ) printf("\nSDL_CreateThread failed: %s\n", SDL_GetError()); else { SDL_WaitThread( thread, &threadReturnValue); printf("\nThread returned value:%d", threadReturnValue); } return 1; } // Very simple thread - counts 0 to 9 delaying 50ms between increments int TestThread( void *ptr ) { int cnt; for(cnt=0;cnt<10;cnt++) { printf( "\nThread counter: %d", cnt); SDL_Delay(50); } return cnt; } |
| Line 26: | Line 69: |
| Line 33: | Line 75: |
| .[[SDL_CreateThread]] * | . [[SDL_CreateThread]] * |
| Line 36: | Line 78: |
| [[CategoryAPI]], [[CategoryThread]] | [[CategoryAPI]], CategoryThread |
DRAFT |
SDL_WaitThread
Use this function to wait for a thread to finish.
Syntax
void SDL_WaitThread(SDL_Thread* thread,
int* status)
Function Parameters
thread |
the thread to wait for |
status |
the pointer to receive the return code???; see Remarks for details |
green
Code Examples
Toggle line numbers
#include <stdio.h>
#include <SDL_thread.h>
#include <SDL_timer.h>
int TestThread( void *ptr );
int main(int argc, char *argv[])
{
SDL_Thread *thread;
int threadReturnValue;
printf("\nSimple SDL_CreateThread test:");
// Simply create a thread
thread = SDL_CreateThread( TestThread, (void *)NULL);
if( NULL == thread )
printf("\nSDL_CreateThread failed: %s\n", SDL_GetError());
else
{
SDL_WaitThread( thread, &threadReturnValue);
printf("\nThread returned value:%d", threadReturnValue);
}
return 1;
}
// Very simple thread - counts 0 to 9 delaying 50ms between increments
int TestThread( void *ptr )
{
int cnt;
for(cnt=0;cnt<10;cnt++)
{
printf( "\nThread counter: %d", cnt);
SDL_Delay(50);
}
return cnt;
}
Remarks
The return code for the thread function is placed in the area pointed to by status, if status is not NULL.
green
