libfilezilla
|
Spawns and represents a new thread of execution. More...
#include <thread.hpp>
Public Types | |
typedef std::thread::id | id |
Public Member Functions | |
~thread () | |
Implicitly calls join() | |
bool | run (std::function< void()> &&f) |
Start the thread. More... | |
void | join () |
Join the thread. More... | |
bool | joinable () const |
A thread is joinable after having been started and before it has been joined. More... | |
Static Public Member Functions | |
static id | own_id () |
Returns unique id of the thread calling the function. | |
Friends | |
class | impl |
Spawns and represents a new thread of execution.
This is a replacement of std::thread. Unfortunately std::thread isn't implemented on all MinGW flavors. Most notably, MinGW as shipped by Debian Jessie does not have std::thread.
This class only supports joinable threads.
void join | ( | ) |
Join the thread.
join blocks until the spawn thread has quit.
You must call this at the latest in the destructor of the most-derived class.
Must not be called from the spawned thread.
After a successful join you can call run again to spawn another thread.
bool joinable | ( | ) | const |
A thread is joinable after having been started and before it has been joined.
Must not be called from the spawned thread.
bool run | ( | std::function< void()> && | f | ) |
Start the thread.
If a thread has already been started and not yet joined, this function fails.