[#BloombergLP-bslmt-ThreadUtilImpl-04] = xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bslmt.adoc[bslmt]::xref:BloombergLP/bslmt/ThreadUtilImpl-0f.adoc[ThreadUtilImpl]<xref:BloombergLP/bslmt/Platform/PosixThreads.adoc[Platform::PosixThreads]> :relfileprefix: ../../ :mrdocs: This class provides a full specialization of `ThreadUtilImpl` for pthreads. == Synopsis Declared in `<bslmt_threadutilimpl_pthread.h>` [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template<> struct xref:BloombergLP/bslmt/ThreadUtilImpl-0f.adoc[ThreadUtilImpl]<xref:BloombergLP/bslmt/Platform/PosixThreads.adoc[Platform::PosixThreads]>; ---- == Type Aliases [cols="1"] |=== | Name | xref:BloombergLP/bslmt/ThreadUtilImpl-04/Handle.adoc[`Handle`] | xref:BloombergLP/bslmt/ThreadUtilImpl-04/Id.adoc[`Id`] | xref:BloombergLP/bslmt/ThreadUtilImpl-04/Key.adoc[`Key`] | xref:BloombergLP/bslmt/ThreadUtilImpl-04/NativeHandle-08.adoc[`NativeHandle`] |=== == Static Member Functions [cols="1,4"] |=== | Name| Description | xref:BloombergLP/bslmt/ThreadUtilImpl-04/areEqual.adoc[`areEqual`] | Return `true` if the specified `a` and `b` thread handles, identify the same thread, and `false` otherwise. | xref:BloombergLP/bslmt/ThreadUtilImpl-04/areEqualId.adoc[`areEqualId`] | Return `true` if the specified `a` and `b` thread id identify the same thread, and `false` otherwise. | xref:BloombergLP/bslmt/ThreadUtilImpl-04/create-09.adoc[`create`] | `create` overloads | xref:BloombergLP/bslmt/ThreadUtilImpl-04/createKey.adoc[`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. | xref:BloombergLP/bslmt/ThreadUtilImpl-04/deleteKey.adoc[`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. | xref:BloombergLP/bslmt/ThreadUtilImpl-04/detach.adoc[`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. | xref:BloombergLP/bslmt/ThreadUtilImpl-04/exit.adoc[`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. | xref:BloombergLP/bslmt/ThreadUtilImpl-04/getMaxSchedulingPriority.adoc[`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. | xref:BloombergLP/bslmt/ThreadUtilImpl-04/getMinSchedulingPriority.adoc[`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. | xref:BloombergLP/bslmt/ThreadUtilImpl-04/getSpecific.adoc[`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. | xref:BloombergLP/bslmt/ThreadUtilImpl-04/getThreadName.adoc[`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. | xref:BloombergLP/bslmt/ThreadUtilImpl-04/handleToId.adoc[`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. | xref:BloombergLP/bslmt/ThreadUtilImpl-04/hardwareConcurrency.adoc[`hardwareConcurrency`] | Return the number of concurrent threads supported by the implementation on success, and 0 otherwise. | xref:BloombergLP/bslmt/ThreadUtilImpl-04/idAsInt.adoc[`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. | xref:BloombergLP/bslmt/ThreadUtilImpl-04/idAsUint64.adoc[`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. | xref:BloombergLP/bslmt/ThreadUtilImpl-04/join.adoc[`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`. | xref:BloombergLP/bslmt/ThreadUtilImpl-04/microSleep.adoc[`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. | xref:BloombergLP/bslmt/ThreadUtilImpl-04/nativeHandle-0a.adoc[`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`). | xref:BloombergLP/bslmt/ThreadUtilImpl-04/self.adoc[`self`] | Return an identifier that can be used to refer to the current thread in future calls to this utility. | xref:BloombergLP/bslmt/ThreadUtilImpl-04/selfId.adoc[`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. | xref:BloombergLP/bslmt/ThreadUtilImpl-04/selfIdAsInt.adoc[`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. | xref:BloombergLP/bslmt/ThreadUtilImpl-04/selfIdAsUint64.adoc[`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. | xref:BloombergLP/bslmt/ThreadUtilImpl-04/selfKernelIdAsUint64.adoc[`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. | xref:BloombergLP/bslmt/ThreadUtilImpl-04/setSpecific.adoc[`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 | xref:BloombergLP/bslmt/ThreadUtilImpl-04/setThreadName.adoc[`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'. | xref:BloombergLP/bslmt/ThreadUtilImpl-04/sleep.adoc[`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. | xref:BloombergLP/bslmt/ThreadUtilImpl-04/sleepUntil-09.adoc[`sleepUntil`] | `sleepUntil` overloads | xref:BloombergLP/bslmt/ThreadUtilImpl-04/yield.adoc[`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 [cols="1"] |=== | Name | xref:BloombergLP/bslmt/ThreadUtilImpl-04/INVALID_HANDLE.adoc[`INVALID_HANDLE`] |=== [.small]#Created with https://www.mrdocs.com[MrDocs]#