zenilib  0.5.3.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
SDL_thread.c File Reference
#include "SDL_config.h"
#include "SDL_thread.h"
#include "SDL_thread_c.h"
#include "SDL_systhread.h"
#include "../SDL_error_c.h"

Go to the source code of this file.

Typedefs

typedef struct SDL_TLSEntry SDL_TLSEntry
 

Functions

DECLSPEC SDL_Thread *SDLCALL SDL_CreateThread (int(SDLCALL *fn)(void *), const char *name, void *data)
 
SDL_TLSDataSDL_Generic_GetTLSData ()
 
int SDL_Generic_SetTLSData (SDL_TLSData *storage)
 
SDL_errorSDL_GetErrBuf (void)
 
SDL_threadID SDL_GetThreadID (SDL_Thread *thread)
 
const char * SDL_GetThreadName (SDL_Thread *thread)
 
void SDL_RunThread (void *data)
 
int SDL_SetThreadPriority (SDL_ThreadPriority priority)
 
static void SDL_TLSCleanup ()
 
SDL_TLSID SDL_TLSCreate ()
 Create an identifier that is globally visible to all threads but refers to data that is thread-specific. More...
 
voidSDL_TLSGet (SDL_TLSID id)
 Get the value associated with a thread local storage ID for the current thread. More...
 
int 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...
 
void SDL_WaitThread (SDL_Thread *thread, int *status)
 

Variables

static SDL_TLSEntrySDL_generic_TLS
 
static SDL_mutexSDL_generic_TLS_mutex
 

Typedef Documentation

typedef struct SDL_TLSEntry SDL_TLSEntry

Function Documentation

int SDL_Generic_SetTLSData ( SDL_TLSData storage)
SDL_threadID 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.

const char* 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.

void SDL_RunThread ( void data)

Definition at line 263 of file SDL_thread.c.

References int, SDL_SemPost(), SDL_SYS_SetupThread(), SDL_ThreadID(), SDL_TLSCleanup(), and SDLCALL.

Referenced by RunThread(), and ThreadEntry().

int 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().

static void SDL_TLSCleanup ( )
static
SDL_TLSID SDL_TLSCreate ( void  )

Create an identifier that is globally visible to all threads but refers to data that is thread-specific.

Returns
The newly created thread local storage identifier, or 0 on error
* static SDL_SpinLock tls_lock;
*
* void SetMyThreadData(void *value)
* {
* SDL_AtomicLock(&tls_lock);
* }
* SDL_AtomicUnLock(&tls_lock);
* }
* }
*
* void *GetMyThreadData(void)
* {
* }
*
See Also
SDL_TLSGet()
SDL_TLSSet()

Definition at line 32 of file SDL_thread.c.

References SDL_AtomicIncRef.

Referenced by SDL_GetErrBuf(), and SDL_VideoInit().

void* SDL_TLSGet ( SDL_TLSID  id)

Get the value associated with a thread local storage ID for the current thread.

Parameters
idThe thread local storage ID
Returns
The value associated with the ID for the current thread, or NULL if no value has been set.
See Also
SDL_TLSCreate()
SDL_TLSSet()

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().

int SDL_TLSSet ( SDL_TLSID  id,
const void value,
void(*)(void *)  destructor 
)

Set the value associated with a thread local storage ID for the current thread.

Parameters
idThe thread local storage ID
valueThe value to associate with the ID for the current thread
destructorA function called when the thread exits, to free the value.
Returns
0 on success, -1 on error
See Also
SDL_TLSCreate()
SDL_TLSGet()

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().

void 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().

Variable Documentation

SDL_TLSEntry* SDL_generic_TLS
static

Definition at line 118 of file SDL_thread.c.

Referenced by SDL_Generic_SetTLSData().

SDL_mutex* SDL_generic_TLS_mutex
static

Definition at line 117 of file SDL_thread.c.