The memory for the variable's data isn't allocated by
tls_allocate(); see
tls_set()
for more information on TLS memory allocation).
| Declared in: | support/TLS.h |
| Library: | libbe.so |
int32 tls_allocate();
Creates and returns a new TLS variable. Each thread in your application
will have its own copy of this variable; setting the value of the
variable (through
tls_set())
in one thread won't affect its value in any
other thread. You should only allocate a TLS variable once per
team—you don't have to allocate it in each thread.
The memory for the variable's data isn't allocated by
tls_allocate(); see
tls_set()
for more information on TLS memory allocation).
void* tls_address(int32 tlsVariable);
Returns the address of the memory that holds the value that's referred to
by tlsVariable. tlsVariable
is a TLS variable that must have been created through
tls_allocate().
The value returned is valid for the calling thread only.
void tls_set(int32 tlsVariable,
void* data);void* tls_get(int32 tlsVariable);
tls_set() sets tlsVariable
to refer to data within the context of the
calling thread. data, which must already be allocated, can point to data
of any size or type. The data needn't be the same type or size for each
thread; for example, a given TLS variable hodgePodge can refer to a
string in one thread, an integer in another, an object in another, and so
on.
tls_get() returns a pointer to the data
referred to by tlsVariable within
the context of the calling thread. If tlsVariable hasn't been allocated
(tls_allocate()),
or if its value hasn't been set (tls_set()), the
function returns NULL.