Nebula
Loading...
Searching...
No Matches
Linux::LinuxThreadLocalData Class Reference

#include <linuxthreadlocaldata.h>

Detailed Description

Thread local data storage class for platforms which don't have a proper __thread implementation but a pthread implementation.

(C) 2011 A.Weissflog (C) 2013-2018 Individual contributors, see AUTHORS file

Static Public Member Functions

static void SetupMainThread ()
 setup the object from the main thread (call from SysFunc::Setup())
 
static IndexT RegisterSlot ()
 register a new slot, this is usually called from the main thread
 
static void SetPointer (IndexT slot, void *ptr)
 set thread local pointer value (must only be called once)
 
static void * GetPointer (IndexT slot)
 get thread local pointer value
 
static void ClearPointer (IndexT slot)
 clear pointer (must only be called after SetPointer)
 

Static Private Member Functions

static void ** GetThreadLocalTable ()
 get pointer to thread locale data table, create table if this is the first call for this thread
 

Static Private Attributes

static const int MaxNumSlots = 4096
 
static pthread_key_t key = 0
 
static IndexT volatile slot = 0
 

Member Function Documentation

◆ ClearPointer()

void Linux::LinuxThreadLocalData::ClearPointer ( IndexT slot)
static

clear pointer (must only be called after SetPointer)

Clear thread-local pointer for a slot.

◆ GetPointer()

void * Linux::LinuxThreadLocalData::GetPointer ( IndexT slot)
static

get thread local pointer value

Get a thread-local pointer for a slot.

◆ GetThreadLocalTable()

void ** Linux::LinuxThreadLocalData::GetThreadLocalTable ( )
staticprivate

get pointer to thread locale data table, create table if this is the first call for this thread

Allocates a new thread-specific data block and sets it as thread-local data.

This is called from SetPointer(), GetPointer() and the other accessor functions.

◆ RegisterSlot()

IndexT Linux::LinuxThreadLocalData::RegisterSlot ( )
static

register a new slot, this is usually called from the main thread

Register a new slot in the thread-locale table.

This is usually called once from the main-thread per thread-local object.

◆ SetPointer()

void Linux::LinuxThreadLocalData::SetPointer ( IndexT slot,
void * ptr )
static

set thread local pointer value (must only be called once)

Set a thread-local pointer for a slot.

This method must only be called once per thread.

◆ SetupMainThread()

void Linux::LinuxThreadLocalData::SetupMainThread ( )
static

setup the object from the main thread (call from SysFunc::Setup())

This method must be called once from the main thread (usually from SysFunc::Setup().

Member Data Documentation

◆ key

pthread_key_t Linux::LinuxThreadLocalData::key = 0
staticprivate

◆ MaxNumSlots

const int Linux::LinuxThreadLocalData::MaxNumSlots = 4096
staticprivate

◆ slot

IndexT volatile Linux::LinuxThreadLocalData::slot = 0
staticprivate

The documentation for this class was generated from the following files: