This struct provides a suite of portable utility functions for managing threads.

Synopsis

Declared in <bslmt_threadutil.h>

struct ThreadUtil;

Type Aliases

Name

Description

Destructor

Prototype for thread‐specific key destructors.

Handle

Thread handle type. Use this type to refer to a thread in a platform‐independent way.

Id

Thread identifier type ‐ distinguished from a Handle in that it does not have any resources associated with it, whereas Handle may, depending on platform.

Imp

Platform‐specific implementation type.

Key

Thread‐specific key type, used to refer to thread‐specific storage.

NativeHandle

Platform‐specific thread handle type.

ThreadFunction

Prototype for thread entry‐point functions.

Static Member Functions

Name

Description

areEqual

Return whether the two thread handles identify the same thread.

areEqualId

Return whether the two thread identifiers refer to the same thread.

convertToSchedulingPriority

Return a platform scheduling priority for the normalized priority.

create

create overloads

createKey

Create a process‐wide key for thread‐local storage.

createWithAllocator

createWithAllocator overloads

deleteKey

Delete the specified process‐wide thread‐local key.

detach

Detach the thread so its resources are reclaimed on termination.

exit

Exit the current thread and return the specified status.

getMaxSchedulingPriority

Return the maximum available scheduling priority for the policy.

getMinSchedulingPriority

Return the minimum available scheduling priority for the policy.

getSpecific

Return the calling thread's value associated with the specified key.

getThreadName

Load the name of the current thread into the specified string.

handleToId

Return the unique identifier for the thread with the specified handle.

hardwareConcurrency

Return a hint at the number of concurrent threads supported by this platform on success, and 0 otherwise.

idAsInt

Return a unique integral identifier for the specified thread.

idAsUint64

Return a unique 64‐bit integral identifier for the specified thread.

invalidHandle

Return a reference to the non‐modifiable Handle object that is guaranteed never to be a valid thread handle.

isEqual

Return whether the two thread handles identify the same thread.

isEqualId

Return whether the two thread identifiers refer to the same thread.

isThreadLimitReached

Return whether the next thread creation should fail due to the limit.

join

Wait for the specified thread to terminate and reclaim its resources.

microSleep

Suspend the current thread for at least the specified duration.

nativeHandle

Return the platform‐specific native handle for the specified thread.

self

Return an opaque handle that refers to the current thread.

selfId

Return a unique identifier for the current thread in this process.

selfIdAsInt

Return a unique integral identifier for the current thread.

selfIdAsUint64

Return a unique 64‐bit integral identifier for the current thread.

selfKernelIdAsUint64

Return a unique 64‐bit identifier for the current kernel thread.

setSpecific

Associate the specified value with the key for the calling thread.

setThreadLimit

Enable a thread‐creation failure limit for testing.

setThreadName

Set the name of the current thread to the specified name.

sleep

Suspend the current thread for at least the specified relative time.

sleepUntil

sleepUntil overloads

yield

Yield the processor so another ready thread can run.

Created with MrDocs