[#BloombergLP-bslmt-ThreadUtilImpl-04]
= xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bslmt.adoc[bslmt]::xref:BloombergLP/bslmt/ThreadUtilImpl-0f.adoc[ThreadUtilImpl]&lt;xref:BloombergLP/bslmt/Platform/PosixThreads.adoc[Platform::PosixThreads]&gt;
:relfileprefix: ../../
:mrdocs:

This class provides a full specialization of `ThreadUtilImpl` for pthreads&period;

== Synopsis

Declared in `&lt;bslmt&lowbar;threadutilimpl&lowbar;pthread&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;&gt;
struct xref:BloombergLP/bslmt/ThreadUtilImpl-0f.adoc[ThreadUtilImpl]&lt;xref:BloombergLP/bslmt/Platform/PosixThreads.adoc[Platform::PosixThreads]&gt;;
----

== 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&period;
| 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&period;
| 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&hyphen;specific pointer value&period; Associate with the identifier, the specified `destructor` if a non&hyphen;zero value is specified&period; Return 0 on success, and a non&hyphen;zero value otherwise&period;
| xref:BloombergLP/bslmt/ThreadUtilImpl-04/deleteKey.adoc[`deleteKey`] 
| Delete the specified thread&hyphen;specific `key`&period; Return 0 on success, and a non&hyphen;zero value otherwise&period; 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&period;
| xref:BloombergLP/bslmt/ThreadUtilImpl-04/detach.adoc[`detach`] 
| &quot;Detach&quot; the thread identified by the specified `threadHandle`, such that when it terminates, the resources associated the thread will automatically be reclaimed&period; Note that once a thread is &quot;detached&quot;, it is no longer possible to `join` the thread to retrieve the its exit status&period;
| xref:BloombergLP/bslmt/ThreadUtilImpl-04/exit.adoc[`exit`] 
| Exit the current thread and return the specified `status`&period; If the current thread is not &quot;detached&quot;, then a call to `join` must be made to reclaim any resources used by the thread, and to retrieve the exit status&period; Note that generally, the preferred method of exiting a thread is to return form the entry point function&period;
| xref:BloombergLP/bslmt/ThreadUtilImpl-04/getMaxSchedulingPriority.adoc[`getMaxSchedulingPriority`] 
| Return the maximum available priority for the specified `policy`, where `policy` is of type `ThreadAttributes&colon;&colon;SchedulingPolicy`&period; Return `ThreadAttributes&colon;&colon;BSLMT&lowbar;UNSET&lowbar;PRIORITY` if the maximum scheduling priority cannot be determined&period; Note that, for some platform &sol; policy combinations, `getMinSchedulingPriority(policy)` and `getMaxSchedulingPriority(policy)` return the same value&period;
| xref:BloombergLP/bslmt/ThreadUtilImpl-04/getMinSchedulingPriority.adoc[`getMinSchedulingPriority`] 
| Return the minimum available priority for the specified `policy`, where `policy` is of type `ThreadAttributes&colon;&colon;SchedulingPolicy`&period; Return `ThreadAttributes&colon;&colon;BSLMT&lowbar;UNSET&lowbar;PRIORITY` if the minimum scheduling priority cannot be determined&period; Note that, for some platform &sol; policy combinations, `getMinSchedulingPriority(policy)` and `getMaxSchedulingPriority(policy)` return the same value&period;
| xref:BloombergLP/bslmt/ThreadUtilImpl-04/getSpecific.adoc[`getSpecific`] 
| Return the value associated with the specified thread&hyphen;specific `key`&period; 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&period;
| xref:BloombergLP/bslmt/ThreadUtilImpl-04/getThreadName.adoc[`getThreadName`] 
| Load the name of the current thread into the specified `threadName`&period; Note that this method clears `&ast;threadName` on all platforms other than Linux and Darwin&period;
| xref:BloombergLP/bslmt/ThreadUtilImpl-04/handleToId.adoc[`handleToId`] 
| Return the unique identifier of the thread having the specified `threadHandle` within the current process&period; Note that this value is only valid until the thread terminates and may be reused thereafter&period;
| xref:BloombergLP/bslmt/ThreadUtilImpl-04/hardwareConcurrency.adoc[`hardwareConcurrency`] 
| Return the number of concurrent threads supported by the implementation on success, and 0 otherwise&period;
| 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&period; Note that this representation is particularly useful for logging purposes&period; Also note that this value is only valid until the thread terminates and may be reused thereafter&period;
| 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&period; Note that this representation is particularly useful for logging purposes&period; Also note that this value is only valid until the thread terminates and may be reused thereafter&period;
| 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`&period; Return 0 on success, and a non&hyphen;zero value otherwise&period; If the optionally specified `status` is not 0, load into the `status` the value returned by the specified `thread`&period;
| 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&period; Return 0 on success, and non&hyphen;zero if the operation was interrupted by a signal&period; Note that the actual time suspended depends on many factors including system scheduling, and system timer resolution&period; Note that the actual time suspended depends on many factors including system scheduling, and system timer resolution&period;
| xref:BloombergLP/bslmt/ThreadUtilImpl-04/nativeHandle-0a.adoc[`nativeHandle`] 
| Return the platform specific identifier associated with the thread specified by `threadHandle`&period; Note that the returned native handle may not be a globally unique identifier for the thread (see `selfIdAsUint`)&period;
| 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&period;
| 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&period; Note that the id is only valid until the thread terminates and may be reused thereafter&period;
| 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&period; This representation is particularly useful for logging purposes&period; Note that this value is only valid until the thread terminates and may be reused thereafter&period;
| 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&period; This representation is particularly useful for logging purposes&period; Note that this value is only valid until the thread terminates and may be reused thereafter&period;
| xref:BloombergLP/bslmt/ThreadUtilImpl-04/selfKernelIdAsUint64.adoc[`selfKernelIdAsUint64`] 
| Return an integral identifier of the current thread used by the operating system&period; Note that kernel thread ID is different from the user&hyphen;space thread ID returned by `selfIdAsUint64()`&period; Note that this value is only valid until the thread terminates and may be reused thereafter&period;
| xref:BloombergLP/bslmt/ThreadUtilImpl-04/setSpecific.adoc[`setSpecific`] 
| Associate the specified `value` with the specified thread&hyphen;specific `key`&period; Return 0 on success, and a non&hyphen;zero value otherwise&period; 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`&period; On all platforms other than Linux and Darwin this method has no effect&period; Note that on those two platforms `threadName` will be truncated to a length of 15 bytes, not including the terminating &apos;0&apos;&period;
| 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&period; Return 0 on success, and a non&hyphen;zero value if the operation was interrupted by a signal&period; Note that the actual time suspended depends on many factors including system scheduling, and system timer resolution&period;
| 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&apos;s queue and schedule another thread to run&period; This allows cooperating threads of the same priority to share CPU resources equally&period;
|===


== Static Data Members

[cols="1"]
|===
| Name
| xref:BloombergLP/bslmt/ThreadUtilImpl-04/INVALID_HANDLE.adoc[`INVALID&lowbar;HANDLE`] 
|===



[.small]#Created with https://www.mrdocs.com[MrDocs]#
