FancySafeBot 0.0.1
A safe robotics library
Loading...
Searching...
No Matches
Posix Threads

Threading for Posix systems. More...

Enumerations

enum class  fsb::ThreadStatus : uint8_t { ThreadStatus::SUCCESS , ThreadStatus::ERROR , ThreadStatus::UNSUPPORTED }
 Status codes for thread operations. More...
 
enum class  fsb::LockStatus : uint8_t { LockStatus::SUCCESS , LockStatus::TIMEOUT , LockStatus::ERROR }
 Status codes for lock and synchronization operations. More...
 

Functions

ThreadStatus fsb::set_thread_priority (pthread_t thread, int policy, int priority)
 Set the scheduling priority of a thread.
 
ThreadStatus fsb::set_thread_cpu_affinity (pthread_t thread, size_t cpu_index)
 Set the CPU affinity of a thread to a specific CPU core.
 
LockStatus fsb::mutex_initialize (pthread_mutex_t &mutex, bool shared=false)
 Initialize a mutex.
 
LockStatus fsb::mutex_lock (pthread_mutex_t &mutex)
 Lock a mutex, blocking until the lock is acquired.
 
LockStatus fsb::mutex_unlock (pthread_mutex_t &mutex)
 Unlock a mutex.
 
LockStatus fsb::mutex_destroy (pthread_mutex_t &mutex)
 Destroy a mutex and release its resources.
 
LockStatus fsb::condvar_initialize (pthread_cond_t &cond_var, bool shared=false)
 Initialize a condition variable.
 
LockStatus fsb::condvar_wait_timeout (pthread_cond_t &cond_var, pthread_mutex_t &mutex, const struct timespec &timeout)
 Wait on a condition variable with a timeout.
 
LockStatus fsb::condvar_signal (pthread_cond_t &cond_var, bool broadcast=false)
 Signal one or all threads waiting on a condition variable.
 
LockStatus fsb::condvar_destroy (pthread_cond_t &cond_var)
 Destroy a condition variable and release its resources.
 

Detailed Description

Threading for Posix systems.

Enumeration Type Documentation

◆ LockStatus

enum class fsb::LockStatus : uint8_t
strong

Status codes for lock and synchronization operations.

Enumerator
SUCCESS 

Operation completed successfully.

TIMEOUT 

Operation timed out.

ERROR 

Operation failed with an error.

◆ ThreadStatus

enum class fsb::ThreadStatus : uint8_t
strong

Status codes for thread operations.

Enumerator
SUCCESS 

Operation completed successfully.

ERROR 

Operation failed with an error.

UNSUPPORTED 

Operation is not supported on this platform.

Function Documentation

◆ condvar_destroy()

LockStatus fsb::condvar_destroy ( pthread_cond_t &  cond_var)

Destroy a condition variable and release its resources.

Parameters
cond_varReference to the condition variable to destroy
Returns
LockStatus indicating success or failure

◆ condvar_initialize()

LockStatus fsb::condvar_initialize ( pthread_cond_t &  cond_var,
bool  shared = false 
)

Initialize a condition variable.

Parameters
cond_varReference to the condition variable to initialize
sharedIf true, condition variable can be shared across processes; if false, only within threads
Returns
LockStatus indicating success or failure

◆ condvar_signal()

LockStatus fsb::condvar_signal ( pthread_cond_t &  cond_var,
bool  broadcast = false 
)

Signal one or all threads waiting on a condition variable.

Parameters
cond_varReference to the condition variable to signal
broadcastIf true, wake all waiting threads; if false, wake only one thread
Returns
LockStatus indicating success or failure

◆ condvar_wait_timeout()

LockStatus fsb::condvar_wait_timeout ( pthread_cond_t &  cond_var,
pthread_mutex_t &  mutex,
const struct timespec &  timeout 
)

Wait on a condition variable with a timeout.

Parameters
cond_varReference to the condition variable to wait on
mutexReference to the mutex associated with the condition variable
timeoutAbsolute time at which to timeout
Returns
LockStatus indicating success, timeout, or failure

◆ mutex_destroy()

LockStatus fsb::mutex_destroy ( pthread_mutex_t &  mutex)

Destroy a mutex and release its resources.

Parameters
mutexReference to the mutex to destroy
Returns
LockStatus indicating success or failure

◆ mutex_initialize()

LockStatus fsb::mutex_initialize ( pthread_mutex_t &  mutex,
bool  shared = false 
)

Initialize a mutex.

Parameters
mutexReference to the mutex to initialize
sharedIf true, mutex can be shared across processes; if false, only within threads
Returns
LockStatus indicating success or failure

◆ mutex_lock()

LockStatus fsb::mutex_lock ( pthread_mutex_t &  mutex)

Lock a mutex, blocking until the lock is acquired.

Parameters
mutexReference to the mutex to lock
Returns
LockStatus indicating success or failure

◆ mutex_unlock()

LockStatus fsb::mutex_unlock ( pthread_mutex_t &  mutex)

Unlock a mutex.

Parameters
mutexReference to the mutex to unlock
Returns
LockStatus indicating success or failure

◆ set_thread_cpu_affinity()

ThreadStatus fsb::set_thread_cpu_affinity ( pthread_t  thread,
size_t  cpu_index 
)

Set the CPU affinity of a thread to a specific CPU core.

Parameters
threadThe pthread handle of the thread to modify
cpu_indexThe index of the CPU core to bind the thread to
Returns
ThreadStatus indicating success or failure

◆ set_thread_priority()

ThreadStatus fsb::set_thread_priority ( pthread_t  thread,
int  policy,
int  priority 
)

Set the scheduling priority of a thread.

Parameters
threadThe pthread handle of the thread to modify
policyThe scheduling policy (e.g., SCHED_FIFO, SCHED_RR, SCHED_OTHER)
priorityThe priority value within the policy's range
Returns
ThreadStatus indicating success or failure