![]() |
Jopnal Engine
alpha 0.4
Simple Component Based 2D/3D Game Engine
|
#include <Thread.hpp>
Public Types | |
| enum | Priority { Priority::Lowest, Priority::Lower, Priority::Normal, Priority::Higher, Priority::Highest } |
Public Member Functions | |
| Thread () | |
| Default constructor. More... | |
| template<typename F , typename... Args> | |
| Thread (F &&func, Args &&...args) | |
| Constructor. More... | |
| Thread (Thread &&other) | |
| Move constructor. More... | |
| Thread & | operator= (Thread &&other) |
| Move assignment operator. More... | |
| ~Thread () | |
| Destructor. More... | |
| void | join () |
| Wait for the thread to return. More... | |
| bool | isJoinable () const |
| Check if this thread is joinable. More... | |
| void | detach () |
| Detach the thread. More... | |
| bool | setPriority (const Priority priority) |
| Set thread priority. More... | |
| void | terminate () |
| Terminate this thread. More... | |
| std::thread::id | getId () const |
| Get the thread identifier. More... | |
Static Public Member Functions | |
| static void | attachJavaThread (void *vm, void *mainEnv) |
| Attach the calling thread to the Java virtual machine. More... | |
| static void | detachJavaThread (void *vm) |
| Detach the calling thread from the Java virtual machine. More... | |
| static _JNIEnv * | getCurrentJavaEnv () |
| Get the JNIEnv for the calling thread. More... | |
Definition at line 36 of file Thread.hpp.
|
strong |
Thread priority
| Enumerator | |
|---|---|
| Lowest | |
| Lower | |
| Normal | |
| Higher | |
| Highest | |
Definition at line 46 of file Thread.hpp.
| jop::Thread::Thread | ( | ) |
Default constructor.
Will not start an actual thread.
|
explicit |
Constructor.
This will start the thread immediately.
| func | The function to use |
| args | Arguments to pass to the function |
| jop::Thread::Thread | ( | Thread && | other | ) |
Move constructor.
| jop::Thread::~Thread | ( | ) |
Destructor.
If the thread is running and hasn't been detached, this will wait until it returns.
|
static |
Attach the calling thread to the Java virtual machine.
A thread needs to be attached if it makes any JNI calls.
On operating systems besides Android, this function is no-op.
| vm | Pointer to the Java virtual machine, may be null |
| mainEnv | Pointer to the NativeActivity JNIEnv, may be null |
| void jop::Thread::detach | ( | ) |
Detach the thread.
After this call the thread is completely independent. join() will have no effect.
|
static |
Detach the calling thread from the Java virtual machine.
On operating systems besides Android, this function is no-op.
| vm | Pointer to the Java virtual machine, may be null |
|
static |
Get the JNIEnv for the calling thread.
| std::thread::id jop::Thread::getId | ( | ) | const |
Get the thread identifier.
| bool jop::Thread::isJoinable | ( | ) | const |
Check if this thread is joinable.
The thread is joinable if it hasn't been detached.
| void jop::Thread::join | ( | ) |
Wait for the thread to return.
This will return immediately if the thread is not joinable.
| bool jop::Thread::setPriority | ( | const Priority | priority | ) |
Set thread priority.
| priority | The priority to set |
| void jop::Thread::terminate | ( | ) |
Terminate this thread.
This method is unsafe. You should always attempt to make your threads return by themselves before resorting to calling this.
1.8.11