TorchCraftAI
A bot for machine learning research on StarCraft: Brood War
|
This class implements a mutex that offers some control over the priority of the waiting threads. More...
#include <prioritymutex.h>
Public Member Functions | |
priority_mutex (int maxPrio) | |
Constructs a mutex. More... | |
priority_mutex (const priority_mutex &)=delete | |
priority_mutex & | operator= (const priority_mutex &)=delete |
priority_mutex (priority_mutex &&)=delete | |
void | lock (int prio=0) |
bool | try_lock (int prio=0) |
void | unlock () |
Protected Member Functions | |
bool | canGo (int prio) |
Protected Attributes | |
std::mutex | queueMutex_ |
std::mutex | dataMutex_ |
std::condition_variable_any | queueCV_ |
std::vector< int > | queueCount_ |
int | maxPrio_ |
This class implements a mutex that offers some control over the priority of the waiting threads.
If several threads are waiting to obtain the lock, it is guaranteed that the one with the highest priority will get it first. If there are several threads with the same priority level, then the outcome is up to the pthread implementation. Note that if there are always high priority threads in the queue, it will create starvation on the lower priority ones. If used inside a lock from the standard library, this will default to locking with the lowest priority
|
inline |
Constructs a mutex.
maxPrio | is the maximal priority level accepted |
|
delete |
|
delete |
|
inlineprotected |
|
inline |
|
delete |
|
inline |
|
inline |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |