zenilib
0.5.3.0
|
#include "SDL_stdinc.h"
#include "SDL_error.h"
#include "SDL_atomic.h"
#include "SDL_mutex.h"
#include "begin_code.h"
#include "close_code.h"
Go to the source code of this file.
Typedefs | |
typedef struct SDL_Thread | SDL_Thread |
typedef unsigned long | SDL_threadID |
typedef unsigned int | SDL_TLSID |
Enumerations | |
enum | SDL_ThreadPriority { SDL_THREAD_PRIORITY_LOW, SDL_THREAD_PRIORITY_NORMAL, SDL_THREAD_PRIORITY_HIGH } |
Functions | |
typedef | int (SDLCALL *SDL_ThreadFunction)(void *data) |
DECLSPEC SDL_Thread *SDLCALL | SDL_CreateThread (SDL_ThreadFunction fn, const char *name, void *data) |
DECLSPEC SDL_threadID SDLCALL | SDL_GetThreadID (SDL_Thread *thread) |
DECLSPEC const char *SDLCALL | SDL_GetThreadName (SDL_Thread *thread) |
DECLSPEC int SDLCALL | SDL_SetThreadPriority (SDL_ThreadPriority priority) |
DECLSPEC SDL_threadID SDLCALL | SDL_ThreadID (void) |
DECLSPEC SDL_TLSID SDLCALL | SDL_TLSCreate (void) |
Create an identifier that is globally visible to all threads but refers to data that is thread-specific. More... | |
DECLSPEC void *SDLCALL | SDL_TLSGet (SDL_TLSID id) |
Get the value associated with a thread local storage ID for the current thread. More... | |
DECLSPEC int SDLCALL | SDL_TLSSet (SDL_TLSID id, const void *value, void(*destructor)(void *)) |
Set the value associated with a thread local storage ID for the current thread. More... | |
DECLSPEC void SDLCALL | SDL_WaitThread (SDL_Thread *thread, int *status) |
typedef struct SDL_Thread SDL_Thread |
Definition at line 46 of file SDL_thread.h.
typedef unsigned long SDL_threadID |
Definition at line 49 of file SDL_thread.h.
Definition at line 52 of file SDL_thread.h.
enum SDL_ThreadPriority |
The SDL thread priority.
Enumerator | |
---|---|
SDL_THREAD_PRIORITY_LOW | |
SDL_THREAD_PRIORITY_NORMAL | |
SDL_THREAD_PRIORITY_HIGH |
Definition at line 59 of file SDL_thread.h.
typedef int | ( | SDLCALL * | SDL_ThreadFunction | ) |
The function passed to SDL_CreateThread(). It is passed a void* user context parameter and returns an int.
DECLSPEC SDL_Thread* SDLCALL SDL_CreateThread | ( | SDL_ThreadFunction | fn, |
const char * | name, | ||
void * | data | ||
) |
Create a thread.
Thread naming is a little complicated: Most systems have very small limits for the string length (BeOS has 32 bytes, Linux currently has 16, Visual C++ 6.0 has nine!), and possibly other arbitrary rules. You'll have to see what happens with your system's debugger. The name should be UTF-8 (but using the naming limits of C identifiers is a better bet). There are no requirements for thread naming conventions, so long as the string is null-terminated UTF-8, but these guidelines are helpful in choosing a name:
http://stackoverflow.com/questions/149932/naming-conventions-for-threads
If a system imposes requirements, SDL will try to munge the string for it (truncate, etc), but the original string contents will be available from SDL_GetThreadName().
Referenced by open_audio_device(), PSP_EventInit(), SDL_SYS_JoystickInit(), and SDL_TimerInit().
DECLSPEC SDL_threadID SDLCALL SDL_GetThreadID | ( | SDL_Thread * | thread | ) |
Get the thread identifier for the specified thread.
Equivalent to SDL_ThreadID() if the specified thread is NULL.
Definition at line 370 of file SDL_thread.c.
References SDL_ThreadID(), and SDL_Thread::threadid.
DECLSPEC const char* SDLCALL SDL_GetThreadName | ( | SDL_Thread * | thread | ) |
Get the thread name, as it was specified in SDL_CreateThread(). This function returns a pointer to a UTF-8 string that names the specified thread, or NULL if it doesn't have a name. This is internal memory, not to be free()'d by the caller, and remains valid until the specified thread is cleaned up by SDL_WaitThread().
Definition at line 383 of file SDL_thread.c.
References SDL_Thread::name, and NULL.
DECLSPEC int SDLCALL SDL_SetThreadPriority | ( | SDL_ThreadPriority | priority | ) |
Set the priority for the current thread
Definition at line 393 of file SDL_thread.c.
References SDL_SYS_SetThreadPriority().
Referenced by SDL_RunAudio().
DECLSPEC SDL_threadID SDLCALL SDL_ThreadID | ( | void | ) |
Get the thread identifier for the current thread.
Definition at line 48 of file SDL_systhread.c.
Referenced by SDL_AudioLockDevice_Default(), SDL_AudioUnlockDevice_Default(), SDL_Generic_GetTLSData(), SDL_Generic_SetTLSData(), SDL_GetThreadID(), SDL_LockMutex(), SDL_mutexP(), SDL_mutexV(), SDL_RunAudio(), SDL_RunThread(), and SDL_TryLockMutex().
Create an identifier that is globally visible to all threads but refers to data that is thread-specific.
Definition at line 32 of file SDL_thread.c.
References SDL_AtomicIncRef.
Referenced by SDL_GetErrBuf(), and SDL_VideoInit().
Get the value associated with a thread local storage ID for the current thread.
id | The thread local storage ID |
Definition at line 39 of file SDL_thread.c.
References SDL_TLSData::array, SDL_TLSData::data, SDL_TLSData::limit, NULL, and SDL_SYS_GetTLSData().
Referenced by SDL_GetErrBuf(), SDL_GL_GetCurrentContext(), and SDL_GL_GetCurrentWindow().
Set the value associated with a thread local storage ID for the current thread.
id | The thread local storage ID |
value | The value to associate with the ID for the current thread |
destructor | A function called when the thread exits, to free the value. |
Definition at line 51 of file SDL_thread.c.
References SDL_TLSData::array, SDL_TLSData::data, SDL_TLSData::destructor, i, SDL_TLSData::limit, NULL, SDL_const_cast, SDL_InvalidParamError, SDL_OutOfMemory, SDL_realloc(), SDL_SYS_GetTLSData(), SDL_SYS_SetTLSData(), and TLS_ALLOC_CHUNKSIZE.
Referenced by SDL_GetErrBuf(), SDL_GL_CreateContext(), and SDL_GL_MakeCurrent().
DECLSPEC void SDLCALL SDL_WaitThread | ( | SDL_Thread * | thread, |
int * | status | ||
) |
Wait for a thread to finish.
The return code for the thread function is placed in the area pointed to by status
, if status
is not NULL.
Definition at line 399 of file SDL_thread.c.
References SDL_Thread::name, SDL_free(), SDL_SYS_WaitThread(), and SDL_Thread::status.
Referenced by close_audio_device(), PSP_EventQuit(), SDL_SYS_JoystickQuit(), and SDL_TimerQuit().