BloombergLP::bslmt::ThreadUtilImpl<Platform::PosixThreads>

This class provides a full specialization of ThreadUtilImpl for pthreads.

Synopsis

Declared in <bslmt_threadutilimpl_pthread.h>

template<>
struct ThreadUtilImpl<Platform::PosixThreads>;

Type Aliases

Name
Handle
Id
Key
NativeHandle

Static Member Functions

NameDescription
areEqual Return true if the specified a and b thread handles, identify the same thread, and false otherwise.
areEqualId Return true if the specified a and b thread id identify the same thread, and false otherwise.
create create overloads
createKey Load, into the specified key, an identifier that can be used to store (setSpecific) and retrieve (getSpecific) a single thread-specific pointer value. Associate with the identifier, the specified destructor if a non-zero value is specified. Return 0 on success, and a non-zero value otherwise.
deleteKey Delete the specified thread-specific key. Return 0 on success, and a non-zero value otherwise. Note that deleting a key does not delete any data that is currently associated with the key in the calling thread or any other thread.
detach "Detach" the thread identified by the specified threadHandle, such that when it terminates, the resources associated the thread will automatically be reclaimed. Note that once a thread is "detached", it is no longer possible to join the thread to retrieve the its exit status.
exit Exit the current thread and return the specified status. If the current thread is not "detached", then a call to join must be made to reclaim any resources used by the thread, and to retrieve the exit status. Note that generally, the preferred method of exiting a thread is to return form the entry point function.
getMaxSchedulingPriority Return the maximum available priority for the specified policy, where policy is of type ThreadAttributes::SchedulingPolicy. Return ThreadAttributes::BSLMT_UNSET_PRIORITY if the maximum scheduling priority cannot be determined. Note that, for some platform / policy combinations, getMinSchedulingPriority(policy) and getMaxSchedulingPriority(policy) return the same value.
getMinSchedulingPriority Return the minimum available priority for the specified policy, where policy is of type ThreadAttributes::SchedulingPolicy. Return ThreadAttributes::BSLMT_UNSET_PRIORITY if the minimum scheduling priority cannot be determined. Note that, for some platform / policy combinations, getMinSchedulingPriority(policy) and getMaxSchedulingPriority(policy) return the same value.
getSpecific Return the value associated with the specified thread-specific key. Note that if the key is not valid, a value of zero is returned, which is indistinguishable from a valid key with a 0 value.
getThreadName Load the name of the current thread into the specified threadName. Note that this method clears *threadName on all platforms other than Linux and Darwin.
handleToId Return the unique identifier of the thread having the specified threadHandle within the current process. Note that this value is only valid until the thread terminates and may be reused thereafter.
hardwareConcurrency Return the number of concurrent threads supported by the implementation on success, and 0 otherwise.
idAsInt Return the unique integral identifier of a thread uniquely identified by the specified threadId within the current process. Note that this representation is particularly useful for logging purposes. Also note that this value is only valid until the thread terminates and may be reused thereafter.
idAsUint64 Return the unique integral identifier of a thread uniquely identified by the specified threadId within the current process. Note that this representation is particularly useful for logging purposes. Also note that this value is only valid until the thread terminates and may be reused thereafter.
join Suspend execution of the current thread until the thread specified by threadHandle terminates, and reclaim any system resources associated with the threadHandle. Return 0 on success, and a non-zero value otherwise. If the optionally specified status is not 0, load into the status the value returned by the specified thread.
microSleep Suspend execution of the current thread for a period of at least the optionally specified seconds and microseconds (relative time), and optionally load into the optionally specified unsleptTime the amount of time that was not slept by this function if the operation was interrupted by a signal. Return 0 on success, and non-zero if the operation was interrupted by a signal. Note that the actual time suspended depends on many factors including system scheduling, and system timer resolution. Note that the actual time suspended depends on many factors including system scheduling, and system timer resolution.
nativeHandle Return the platform specific identifier associated with the thread specified by threadHandle. Note that the returned native handle may not be a globally unique identifier for the thread (see selfIdAsUint).
self Return an identifier that can be used to refer to the current thread in future calls to this utility.
selfId Return an identifier that can be used to uniquely identify the current thread within the current process. Note that the id is only valid until the thread terminates and may be reused thereafter.
selfIdAsInt Return an integeral identifier that can be used to uniquely identify the current thread within the current process. This representation is particularly useful for logging purposes. Note that this value is only valid until the thread terminates and may be reused thereafter.
selfIdAsUint64 Return an integral identifier that can be used to uniquely identify the current thread within the current process. This representation is particularly useful for logging purposes. Note that this value is only valid until the thread terminates and may be reused thereafter.
selfKernelIdAsUint64 Return an integral identifier of the current thread used by the operating system. Note that kernel thread ID is different from the user-space thread ID returned by selfIdAsUint64(). Note that this value is only valid until the thread terminates and may be reused thereafter.
setSpecific Associate the specified value with the specified thread-specific key. Return 0 on success, and a non-zero value otherwise. TBD elaborate on what value represents
setThreadName Set the name of the current thread to the specified threadName. On all platforms other than Linux and Darwin this method has no effect. Note that on those two platforms threadName will be truncated to a length of 15 bytes, not including the terminating '0'.
sleep Suspend execution of the current thread for a period of at least the specified sleepTime (relative time), and optionally load into the optionally specified unsleptTime the amount of time that was not slept by this function if the operation was interrupted by a signal. Return 0 on success, and a non-zero value if the operation was interrupted by a signal. Note that the actual time suspended depends on many factors including system scheduling, and system timer resolution.
sleepUntil sleepUntil overloads
yield Put the current thread to the end of the scheduler's queue and schedule another thread to run. This allows cooperating threads of the same priority to share CPU resources equally.

Static Data Members

Name
INVALID_HANDLE