40#include <libexcept/scoped_signal_mask.h>
70 thread(std::string
const & name, std::shared_ptr<runner>
runner);
76 std::string
const &
get_name()
const;
81 void stop(std::function<
void(
thread *)> callback =
nullptr);
102 std::string
const f_name = std::string();
A mutex object to ensures atomicity.
The runner is the class that wraps the actual system thread.
A thread object that ensures proper usage of system threads.
void mask_all_signals()
Block all signals for this thread.
bool f_stopping
The thread is currently in the stopping process.
void mask_signals(libexcept::sig_list_t list)
Masks signals from this thread.
thread(thread const &rhs)=delete
The copy operator is deleted.
thread & operator=(thread const &rhs)=delete
The assignment operator is deleted.
pid_t f_tid
This thread identifier.
std::exception_ptr f_exception
An exception pointer.
pthread_attr_t f_thread_attr
This thread attributes.
std::shared_ptr< thread > pointer_t
The shared pointer for a thread object.
void set_log_all_exceptions(bool log_all_exceptions)
Whether to log exceptions caught in the thread.
void init()
This private function initializes the thread.
runner * get_runner() const
Get a pointer to this thread runner.
std::string const f_name
The name of this thread.
bool is_running() const
Check whether the thread is considered to be running.
bool internal_run()
Execute the run() function.
bool get_log_all_exceptions() const
Retrieve whether all exceptions get logged or not.
friend void * func_internal_start(void *system_thread)
Start the actual thread.
void internal_thread()
Run the thread process.
std::vector< pointer_t > vector_t
A vector of threads.
mutex f_mutex
The thread mutex to guard various functions.
runner * f_runner
The actual thread object.
void stop(std::function< void(thread *)> callback=nullptr)
Stop the thread.
bool is_stopping() const
Check whether the thread was asked to stop.
std::exception_ptr get_exception() const
Get the exception pointer.
pthread_t f_thread_id
This thread identifier.
~thread()
Delete a thread object.
void unmask_signals(libexcept::sig_list_t list)
Unmask signals for this thread.
bool f_started
The thread is started.
std::string const & get_name() const
Retrieve the name of this process object.
bool f_running
The thread is running.
mutex & get_thread_mutex() const
Retrieve a reference to the thread mutex.
bool internal_enter()
Enter the thread runner.
void internal_leave(leave_status_t status)
Function called when leaving the thread runner.
bool start()
Attempt to start the thread.
pid_t get_thread_tid() const
Retrieve the thread identifier of this thread.
bool f_log_all_exceptions
Whether the runner exceptions should be logged or not.
bool kill(int sig)
Send a signal to this thread.
int deswappify(pid_t pid)
Go through the swapped out sections of a process and deswappify them.
Thread Runner and Managers.
leave_status_t
The exit status.
bool is_process_running(pid_t pid)
Check whether a process is running or not.
pid_t gettid()
Get the thread identifier of the current thread.
std::size_t get_thread_count()
Get the number of threads still not joined in this process.
int set_current_thread_name(std::string const &name)
Set the name of the currently running thread.
int set_thread_name(pid_t tid, std::string const &name)
Set the name of the specified thread.
process_ids_t get_thread_ids(pid_t pid)
Retrieve the list of threads for a given process.
bool is_using_vdso()
Certain functions may be implemented using the vDSO library.
pid_t get_pid_max()
Get the maximum process identifier.
int get_total_number_of_processors()
Retrieve the number of processors available on this system.
std::string get_boot_id()
Retrieve the boot UUID.
std::string get_thread_name(pid_t tid)
Retrieve the name of a thread.
int get_number_of_available_processors()
Retrieve the number of processors currently usable.
std::string get_current_thread_name()
Retrieve the name of the current thread.
std::vector< pid_t > process_ids_t
A list of identifiers representing various processes.
constexpr pid_t PID_UNDEFINED
The value a PID variable is set to when not representing a process.
constexpr pthread_t THREAD_UNDEFINED
An invalid thread identifier for initialization.