ORIGINAL
|
High-level thread wrapper. More...
#include <thread.h>
Public Member Functions | |
thread () | |
Construct empty thread. | |
template<typename Callback , typename... ARGS> | |
thread (Callback c, ARGS &&... args) | |
Construct and start thread with callback (AUTO_JOIN policy) | |
template<typename Callback , typename... ARGS> | |
thread (Callback c, joinPolicy policy, ARGS &&... args) | |
Construct and start a thread with the given callback and join policy. | |
thread (pThread p_thread, joinPolicy policy=AUTO_JOIN) | |
Construct a thread from an existing pThread with a join policy. | |
thread (const thread &)=delete | |
Deleted copy constructor. | |
thread & | operator= (const thread &)=delete |
Deleted copy assignment. | |
thread (thread &&other) noexcept | |
Move constructor (defaults to AUTO_JOIN) | |
thread (thread &&other, joinPolicy policy) noexcept | |
Move constructor with specified join policy. | |
thread & | operator= (thread &&other) noexcept |
Move assignment. | |
ul_integer | id () const override |
Get thread identifier. | |
bool | joinable () const override |
Check if thread is joinable. | |
integer | compareTo (const thread &other) const override |
u_integer | toHash () const noexcept override |
Computes the hash of the object. | |
std::string | className () const override |
Gets the class name for type identification. | |
void | join () override |
Wait for thread to complete. | |
void | detach () override |
Detach thread (allow it to run independently) | |
~thread () override | |
Destructor. | |
![]() | |
threadBase () noexcept=default | |
Default constructor. | |
threadBase (const threadBase &)=delete | |
Deleted copy constructor. | |
threadBase (threadBase &&other) noexcept=default | |
Default move constructor. | |
~threadBase () noexcept override=default | |
Destructor. | |
threadBase & | operator= (const threadBase &)=delete |
Deleted copy assignment. | |
threadBase & | operator= (threadBase &&other) noexcept=default |
Default move assignment. | |
operator bool () const | |
Check if thread is valid. | |
bool | operator! () const |
Check if thread is not valid. | |
std::string | className () const override |
Gets the class name for type identification. | |
std::string | toString (bool enter) const override |
Generates formatted string representation. | |
![]() | |
virtual integer | compareTo (const DERIVED &other) const =0 |
Compares the current object with another of the same type. | |
bool | operator== (const DERIVED &other) const |
Checks if the current object is equal to another. | |
bool | operator!= (const DERIVED &other) const |
Checks if the current object is not equal to another. | |
bool | operator< (const DERIVED &other) const |
Checks if the current object is less than another. | |
bool | operator> (const DERIVED &other) const |
Checks if the current object is greater than another. | |
bool | operator<= (const DERIVED &other) const |
Checks if the current object is less than or equal to another. | |
bool | operator>= (const DERIVED &other) const |
Checks if the current object is greater than or equal to another. | |
virtual | ~comparable ()=default |
Virtual destructor for proper cleanup of derived objects. | |
![]() | |
virtual bool | equals (const DERIVED &other) const noexcept |
Compares two objects for equality. | |
virtual | ~hashable ()=0 |
Virtual destructor. | |
![]() | |
operator std::string () const | |
Explicit conversion to std::string. | |
operator const char * () const | |
Explicit conversion to C-style string. | |
const char * | toCString (bool enter) const |
Direct C-string access with formatting control. | |
template<typename TYPE > | |
auto | formatString (const TYPE &t) -> std::string |
template<typename TYPE > | |
auto | formatCString (const TYPE &t) -> const char * |
template<typename TYPE > | |
auto | formatEnum (const TYPE &t) -> std::string |
template<typename TYPE > | |
auto | formatString (TYPE *const &ptr) -> std::string |
Static Public Member Functions | |
static ul_integer | thisId () |
static void | sleep (const time::duration &d) |
Puts the current thread to sleep for a specified duration. | |
![]() | |
template<typename TYPE > | |
static std::string | formatString (const TYPE &t) |
Universal value-to-string conversion with type-specific formatting. | |
template<Printable TYPE> | |
static std::string | formatString (const TYPE &t) |
Specialization for types deriving from printable. | |
template<EnumType TYPE> | |
static std::string | formatString (const TYPE &t) |
Specialization for enum types with type-safe formatting. | |
template<typename TYPE > | |
static std::string | formatString (TYPE *const &ptr) |
Pointer-specific formatting with null safety. | |
template<typename TYPE > | |
static const char * | formatCString (const TYPE &t) |
C-string cache for temporary usage with static storage. | |
template<typename TYPE > | |
static std::string | formatEnum (const TYPE &t) |
Enum formatting utility with underlying value extraction. | |
template<> | |
auto | formatString (const char &t) -> std::string |
template<> | |
auto | formatString (const bool &t) -> std::string |
template<> | |
auto | formatString (const char *const &ptr) -> std::string |
Static Public Attributes | |
static constexpr auto | AUTO_JOIN = joinPolicy::AUTO_JOIN |
Alias for joinPolicy::AUTO_JOIN. | |
static constexpr auto | AUTO_DETACH = joinPolicy::AUTO_DETACH |
Alias for joinPolicy::AUTO_DETACH. | |
Additional Inherited Members |
High-level thread wrapper.
Manages thread lifetime with automatic join/detach. Provides RAII semantics for thread management with configurable join policy. Implements threadBase interface while wrapping a pThread instance.
Key Features:
Join Policy:
Example usage:
|
inlineexplicit |
Construct empty thread.
Construct and start thread with callback (AUTO_JOIN policy)
Callback | Callable type |
ARGS | Argument types |
c | Callable to execute in thread |
args | Arguments forwarded to the callable |
Construct and start a thread with the given callback and join policy.
Callback | Type of the callable object |
ARGS | Types of arguments to pass to the callable |
c | Callable object to run in the new thread |
policy | Join policy (AUTO_JOIN or AUTO_DETACH) |
args | Arguments forwarded to the callable |
Construct a thread from an existing pThread with a join policy.
p_thread | The POSIX thread wrapper to take ownership of |
policy | Join policy (AUTO_JOIN or AUTO_DETACH) |
|
inlinenoexcept |
Move constructor (defaults to AUTO_JOIN)
other | Thread to move from |
|
inlinenoexcept |
Move constructor with specified join policy.
other | Thread to move from |
policy | Join policy (AUTO_JOIN or AUTO_DETACH) |
|
inlineoverride |
Destructor.
|
inlineoverridevirtual |
Gets the class name for type identification.
Override in derived classes to provide accurate type names.
Reimplemented from original::printable.
|
inlineoverridevirtual |
Detach thread (allow it to run independently)
Implements original::threadBase< thread >.
|
inlineoverridevirtual |
Get thread identifier.
Implements original::threadBase< thread >.
|
inlineoverridevirtual |
Wait for thread to complete.
Implements original::threadBase< thread >.
|
inlineoverridevirtual |
Check if thread is joinable.
Implements original::threadBase< thread >.
|
inlinenoexcept |
Move assignment.
other | Thread to move from |
|
inlinestatic |
Puts the current thread to sleep for a specified duration.
d | Duration to sleep |
sysError | if sleep operation fails (except on Windows) |
|
inlineoverridevirtualnoexcept |
Computes the hash of the object.
Default implementation uses byte-wise hashing of object representation. Override for custom hashing logic.
Reimplemented from original::hashable< DERIVED >.
|
staticconstexpr |
Alias for joinPolicy::AUTO_DETACH.
The thread is detached in the destructor (non-blocking cleanup).
|
staticconstexpr |
Alias for joinPolicy::AUTO_JOIN.
The thread is joined in the destructor (blocking cleanup).