MapLibre Native Core
|
Manages a thread with Object
.
More...
#include <thread.hpp>
Public Member Functions | |
template<typename TupleArgs > | |
Thread (std::function< void()> prioritySetter_, const std::string &name, TupleArgs &&args) | |
template<typename... Args> | |
Thread (const std::string &name, Args &&... args) | |
template<typename... Args> | |
Thread (const std::function< void()> &prioritySetter, const std::string &name, Args &&... args) | |
~Thread () | |
ActorRef< std::decay_t< Object > > | actor () |
void | pause () |
void | resume () |
Manages a thread with Object
.
Upon creation of this object, it launches a thread and creates an object of type Object
in that thread. When the Thread<>
object is destructed, the destructor waits for thread termination. The Thread<>
constructor blocks until the thread and the Object
are fully created, so after the object creation, it's safe to obtain the Object
stored in this thread. The thread created will always have low priority on the platforms that support setting thread priority.
The following properties make this class different from ThreadPool
:
Object
will live in a single thread, providing thread affinity.ThreadLocal
in an Object
managed by Thread<>
RunLoop
is created for the Object
thread.Object
can use Timer
and do asynchronous I/O, like wait for sockets events. Definition at line 40 of file thread.hpp.
|
inline |
Definition at line 43 of file thread.hpp.
|
inline |
Definition at line 75 of file thread.hpp.
|
inline |
Definition at line 79 of file thread.hpp.
|
inline |
Definition at line 82 of file thread.hpp.
|
inline |
Returns a non-owning reference to Object
that can be used to send messages to Object
. It is safe to the non-owning reference to outlive this object and be used after the Thread<>
gets destroyed.
Definition at line 107 of file thread.hpp.
|
inline |
Pauses the Object
thread. It will prevent the object to wake up from events such as timers and file descriptor I/O. Messages sent to a paused Object
will be queued and only processed after resume()
is called.
Definition at line 115 of file thread.hpp.
|
inline |
Definition at line 137 of file thread.hpp.