zenilib: zenilib/jni/external/sdl/src/thread/SDL_thread.c File Reference

zenilib 0.5.3.0

- Main Page
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Typedefs | Functions | Variables
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_TLSData * | SDL_Generic_GetTLSData ()
int | SDL_Generic_SetTLSData (SDL_TLSData *storage)
SDL_error * | SDL_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...
void * | SDL_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_TLSEntry * | SDL_generic_TLS
static SDL_mutex * | SDL_generic_TLS_mutex

## Typedef Documentation

typedef struct SDL_TLSEntry SDL_TLSEntry

## Function Documentation

DECLSPEC SDL_Thread* SDLCALL SDL_CreateThread | ( | int(SDLCALL *fn)(void *) | ,
|  | const char * | name,
|  | void * | data
| ) |  |

Definition at line 295 of file SDL_thread.c.

References SDL_Thread::name, NULL, ret, SDL_CreateSemaphore(), SDL_DestroySemaphore(), SDL_free(), SDL_malloc(), SDL_memset(), SDL_OutOfMemory, SDL_SemWait(), SDL_strdup(), SDL_SYS_CreateThread(), SDL_Thread::status, and thread.

SDL_TLSData* SDL_Generic_GetTLSData | ( |  | ) |

Definition at line 122 of file SDL_thread.c.

References NULL, SDL_AtomicLock(), SDL_AtomicUnlock(), SDL_CreateMutex(), SDL_LockMutex(), SDL_MemoryBarrierAcquire, SDL_MemoryBarrierRelease, SDL_ThreadID(), SDL_UnlockMutex(), and thread.

Referenced by SDL_SYS_GetTLSData().

int SDL_Generic_SetTLSData | ( | SDL_TLSData * | storage | ) |

Definition at line 161 of file SDL_thread.c.

References NULL, SDL_free(), SDL_generic_TLS, SDL_LockMutex(), SDL_malloc(), SDL_OutOfMemory, SDL_ThreadID(), SDL_UnlockMutex(), and thread.

Referenced by SDL_SYS_SetTLSData().

SDL_error* SDL_GetErrBuf | ( | void |  | ) |

Definition at line 204 of file SDL_thread.c.

References NULL, SDL_AtomicLock(), SDL_AtomicUnlock(), SDL_FALSE, SDL_free(), SDL_malloc(), SDL_MemoryBarrierAcquire, SDL_MemoryBarrierRelease, SDL_TLSCreate(), SDL_TLSGet(), SDL_TLSSet(), SDL_TRUE, and SDL_zerop.

Referenced by SDL_ClearError(), SDL_GetErrorMsg(), and SDL_SetError().

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

Definition at line 85 of file SDL_thread.c.

References SDL_TLSData::array, SDL_TLSData::data, SDL_TLSData::destructor, i, SDL_TLSData::limit, NULL, SDL_free(), SDL_SYS_GetTLSData(), and SDL_SYS_SetTLSData().

Referenced by SDL_RunThread().

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;
* static SDL_TLSID thread_local_storage;
*
* void SetMyThreadData(void *value)
* {
* if (!thread_local_storage) {
* SDL_AtomicLock(&tls_lock);
* if (!thread_local_storage) {
* thread_local_storage = SDL_TLSCreate();
* }
* SDL_AtomicUnLock(&tls_lock);
* }
* SDL_TLSSet(thread_local_storage, value);
* }
*
* void *GetMyThreadData(void)
* {
* return SDL_TLSGet(thread_local_storage);
* }
*

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

  id | The 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

  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.

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.