ORIGINAL
Loading...
Searching...
No Matches
Public Member Functions | List of all members
original::pThread Class Referencefinal

POSIX thread implementation. More...

#include <thread.h>

Inheritance diagram for original::pThread:
Inheritance graph
Collaboration diagram for original::pThread:
Collaboration graph

Public Member Functions

 pThread ()
 Construct empty (invalid) thread.
 
template<typename Callback , typename... ARGS>
 pThread (Callback c, ARGS &&... args)
 Construct and start POSIX thread.
 
 pThread (pThread &&other) noexcept
 Move constructor.
 
pThreadoperator= (pThread &&other) noexcept
 Move assignment.
 
ul_integer id () const override
 Get thread identifier.
 
bool joinable () const override
 Check if thread is joinable.
 
integer compareTo (const pThread &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)
 
 ~pThread () override
 Destructor.
 
- Public Member Functions inherited from original::threadBase< pThread >
 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.
 
threadBaseoperator= (const threadBase &)=delete
 Deleted copy assignment.
 
threadBaseoperator= (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.
 
- Public Member Functions inherited from original::comparable< DERIVED >
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.
 
- Public Member Functions inherited from original::hashable< DERIVED >
virtual bool equals (const DERIVED &other) const noexcept
 Compares two objects for equality.
 
virtual ~hashable ()=0
 Virtual destructor.
 
- Public Member Functions inherited from original::printable
 operator std::string () const
 Explicit conversion to std::string.
 
 operator const char * () const
 Explicit conversion to C-style string.
 
const chartoCString (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
 

Additional Inherited Members

- Static Public Member Functions inherited from original::printable
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 charformatCString (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
 

Detailed Description

POSIX thread implementation.

Wrapper around pthread with RAII semantics. Provides low-level thread management using POSIX threads API.

Note
This class is not thread-safe for concurrent operations on the same object
Implements the threadBase interface for POSIX threads

Constructor & Destructor Documentation

◆ pThread() [1/3]

original::pThread::pThread ( )
inlineexplicit

Construct empty (invalid) thread.

Postcondition
Creates a thread object not associated with any execution

◆ pThread() [2/3]

template<typename Callback , typename... ARGS>
original::pThread::pThread ( Callback  c,
ARGS &&...  args 
)
explicit

Construct and start POSIX thread.

Template Parameters
CallbackCallback function type
ARGSArgument types for callback
Parameters
cCallback function to execute in new thread
argsArguments to forward to callback
Exceptions
sysErrorif thread creation fails
Postcondition
New thread starts executing the callback with provided arguments

◆ pThread() [3/3]

original::pThread::pThread ( pThread &&  other)
inlinenoexcept

Move constructor.

Parameters
otherThread to move from
Postcondition
Source thread becomes invalid

◆ ~pThread()

original::pThread::~pThread ( )
inlineoverride

Destructor.

Note
Terminates program if thread is joinable and not joined/detached

Member Function Documentation

◆ className()

std::string original::pThread::className ( ) const
inlineoverridevirtual

Gets the class name for type identification.

Returns
Class name as string.

Override in derived classes to provide accurate type names.

class MyClass : public printable {
std::string className() const override { return "MyClass"; }
};
Unique ownership smart pointer with move semantics.
Definition ownerPtr.h:37
Base class providing polymorphic string conversion capabilities.
Definition printable.h:39

Reimplemented from original::printable.

◆ detach()

void original::pThread::detach ( )
inlineoverridevirtual

Detach thread (allow it to run independently)

Note
Terminates program if detach fails
After detach, the thread object no longer represents the thread

Implements original::threadBase< pThread >.

◆ id()

original::ul_integer original::pThread::id ( ) const
inlineoverridevirtual

Get thread identifier.

Returns
Unique identifier for the thread

Implements original::threadBase< pThread >.

◆ join()

void original::pThread::join ( )
inlineoverridevirtual

Wait for thread to complete.

Note
Terminates program if join fails
Blocks until the thread completes execution

Implements original::threadBase< pThread >.

◆ joinable()

bool original::pThread::joinable ( ) const
inlineoverridevirtual

Check if thread is joinable.

Returns
true if thread is joinable
Note
Implementation of threadBase::joinable()

Implements original::threadBase< pThread >.

◆ operator=()

original::pThread & original::pThread::operator= ( pThread &&  other)
inlinenoexcept

Move assignment.

Parameters
otherThread to move from
Returns
Reference to this object
Postcondition
Source thread becomes invalid

◆ toHash()

original::u_integer original::pThread::toHash ( ) const
inlineoverridevirtualnoexcept

Computes the hash of the object.

Returns
A hash value

Default implementation uses byte-wise hashing of object representation. Override for custom hashing logic.

Reimplemented from original::hashable< DERIVED >.


The documentation for this class was generated from the following file: