Zycore 1.5.1.0
Loading...
Searching...
No Matches
Functions
Thread.h File Reference
#include <Zycore/Defines.h>
#include <Zycore/Status.h>
Include dependency graph for Thread.h:

Go to the source code of this file.

Functions

ZYCORE_EXPORT ZyanStatus ZyanThreadGetCurrentThread (ZyanThread *thread)
 
ZYCORE_EXPORT ZyanStatus ZyanThreadGetCurrentThreadId (ZyanThreadId *thread_id)
 
ZYCORE_EXPORT ZyanStatus ZyanThreadTlsAlloc (ZyanThreadTlsIndex *index, ZyanThreadTlsCallback destructor)
 
ZYCORE_EXPORT ZyanStatus ZyanThreadTlsFree (ZyanThreadTlsIndex index)
 
ZYCORE_EXPORT ZyanStatus ZyanThreadTlsGetValue (ZyanThreadTlsIndex index, void **data)
 
ZYCORE_EXPORT ZyanStatus ZyanThreadTlsSetValue (ZyanThreadTlsIndex index, void *data)
 

Function Documentation

◆ ZyanThreadGetCurrentThread()

ZYCORE_EXPORT ZyanStatus ZyanThreadGetCurrentThread ( ZyanThread *  thread)

Returns the handle of the current thread.

Parameters
threadReceives the handle of the current thread.
Returns
A zyan status code.

◆ ZyanThreadGetCurrentThreadId()

ZYCORE_EXPORT ZyanStatus ZyanThreadGetCurrentThreadId ( ZyanThreadId *  thread_id)

Returns the unique id of the current thread.

Parameters
thread_idReceives the unique id of the current thread.
Returns
A zyan status code.

◆ ZyanThreadTlsAlloc()

ZYCORE_EXPORT ZyanStatus ZyanThreadTlsAlloc ( ZyanThreadTlsIndex *  index,
ZyanThreadTlsCallback  destructor 
)

Allocates a new Thread Local Storage (TLS) slot.

Parameters
indexReceives the TLS slot index.
destructorA pointer to a destructor callback which is invoked to finalize the data in the TLS slot or ZYAN_NULL, if not needed.

The maximum available number of TLS slots is implementation specific and different on each platform:

  • Windows
    • A total amount of 128 slots per process are guaranteed
  • POSIX
    • A total amount of 128 slots per process are guaranteed
    • Some systems guarantee larger amounts like e.g. 1024 slots per process

Note that the invocation rules for the destructor callback are implementation specific and different on each platform:

  • Windows
    • The callback is invoked when a thread exits
    • The callback is invoked when the process exits
    • The callback is invoked when the TLS slot is released
  • POSIX
    • The callback is invoked when a thread exits and the stored value is not null
    • The callback is NOT invoked when the process exits
    • The callback is NOT invoked when the TLS slot is released
Returns
A zyan status code.

◆ ZyanThreadTlsFree()

ZYCORE_EXPORT ZyanStatus ZyanThreadTlsFree ( ZyanThreadTlsIndex  index)

Releases a Thread Local Storage (TLS) slot.

Parameters
indexThe TLS slot index.
Returns
A zyan status code.

◆ ZyanThreadTlsGetValue()

ZYCORE_EXPORT ZyanStatus ZyanThreadTlsGetValue ( ZyanThreadTlsIndex  index,
void **  data 
)

Returns the value inside the given Thread Local Storage (TLS) slot for the calling thread.

Parameters
indexThe TLS slot index.
dataReceives the value inside the given Thread Local Storage (TLS) slot for the calling thread.
Returns
A zyan status code.

◆ ZyanThreadTlsSetValue()

ZYCORE_EXPORT ZyanStatus ZyanThreadTlsSetValue ( ZyanThreadTlsIndex  index,
void *  data 
)

Set the value of the given Thread Local Storage (TLS) slot for the calling thread.

Parameters
indexThe TLS slot index.
dataThe value to store inside the given Thread Local Storage (TLS) slot for the calling thread
Returns
A zyan status code.