Go to the documentation of this file.
215 void cancel() noexcept {pthread_cancel(thread);}
227 void join() noexcept {pthread_join(thread, 0);}
236 void detach() noexcept {pthread_detach(thread);}
252 bool is_caller() noexcept {
return pthread_equal(thread, pthread_self());}
377 class =
typename std::enable_if<!std::is_convertible<typename std::remove_reference<F>::type,
379 static std::unique_ptr<Cgu::Thread::Thread>
start(F&& func,
381 return start(Cgu::Callback::lambda<>(std::forward<F>(func)), joinable);
384 #ifdef CGU_USE_GLIB_MEMORY_SLICES_NO_COMPAT
480 std::unique_ptr<Cgu::Thread::Thread> thread;
630 JoinableHandle(std::unique_ptr<Cgu::Thread::Thread> thr,
Action act): action(act), detached(false), thread(std::move(thr)) {}
750 static int block(
int& old_state) noexcept {
return pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &old_state);}
761 static int block() noexcept {
int old_state;
return block(old_state);}
778 static int unblock(
int& old_state) noexcept {
return pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, &old_state);}
804 int restore(
int& old_state) noexcept {
return pthread_setcancelstate(starting_state, &old_state);}
The callback interface class.
Definition: callback.h:650
void cancel() noexcept
Definition: thread.h:215
Definition: application.h:44
A class wrapping a Thread::Thread object representing a joinable thread.
Definition: thread.h:472
static int block() noexcept
Definition: thread.h:761
void detach() noexcept
Definition: thread.h:236
@ join_on_exit
Definition: thread.h:474
CancelBlock & operator=(const CancelBlock &)=delete
JoinableHandle()
Definition: thread.h:669
~CancelBlock()
Definition: thread.h:829
CancelBlock(const CancelBlock &)=delete
bool is_caller() noexcept
Definition: thread.h:252
void join() noexcept
Definition: thread.h:227
Thread(const Thread &)=delete
CancelBlock(bool blocking=true)
This file provides classes for type erasure.
Action
Definition: thread.h:474
A class which can be thrown to terminate the throwing thread.
Definition: thread.h:855
int restore(int &old_state) noexcept
Definition: thread.h:804
JoinableHandle(JoinableHandle &&h)
Definition: thread.h:657
Thread & operator=(const Thread &)=delete
#define CGU_GLIB_MEMORY_SLICES_FUNCS
Definition: cgu_config.h:84
@ detach_on_exit
Definition: thread.h:474
A class enabling the cancellation state of a thread to be controlled.
Definition: thread.h:723
Provides wrapper classes for pthread mutexes and condition variables, and scoped locking classes for ...
JoinableHandle & operator=(JoinableHandle &&h)
static int unblock() noexcept
Definition: thread.h:790
static int unblock(int &old_state) noexcept
Definition: thread.h:778
int restore() noexcept
Definition: thread.h:813
static std::unique_ptr< Cgu::Thread::Thread > start(F &&func, bool joinable)
Definition: thread.h:379
A wrapper class for pthread mutexes.
Definition: mutex.h:117
JoinableHandle(std::unique_ptr< Cgu::Thread::Thread > thr, Action act)
Definition: thread.h:630
A class representing a pthread thread.
Definition: thread.h:166
static int block(int &old_state) noexcept
Definition: thread.h:750
static std::unique_ptr< Cgu::Thread::Thread > start(const Cgu::Callback::Callback *cb, bool joinable)