Beatmup
|
Basic class: task and memory management, any kind of static data. More...
#include <context.h>
Classes | |
class | EventListener |
An event listener (bunch of callbacks) More... | |
class | Impl |
Context class implementation (pimpl) More... | |
Public Member Functions | |
Context () | |
Context (const PoolIndex numThreadPools) | |
~Context () | |
float | performTask (AbstractTask &task, const PoolIndex pool=DEFAULT_POOL) |
Performs a given task. More... | |
void | repeatTask (AbstractTask &task, bool abortCurrent, const PoolIndex pool=DEFAULT_POOL) |
Ensures a given task executed at least once. More... | |
Job | submitTask (AbstractTask &task, const PoolIndex pool=DEFAULT_POOL) |
Adds a new task to the jobs queue. More... | |
Job | submitPersistentTask (AbstractTask &task, const PoolIndex pool=DEFAULT_POOL) |
Adds a new persistent task to the jobs queue. More... | |
void | waitForJob (Job job, const PoolIndex pool=DEFAULT_POOL) |
Waits until a given job finishes. More... | |
bool | abortJob (Job job, const PoolIndex pool=DEFAULT_POOL) |
Aborts a given submitted job. More... | |
void | wait (const PoolIndex pool=DEFAULT_POOL) |
Blocks until all the submitted jobs are executed. More... | |
bool | busy (const PoolIndex pool=DEFAULT_POOL) |
Queries whether a given thread pool is busy with a task. More... | |
void | check (const PoolIndex pool=DEFAULT_POOL) |
Checks if a specific thread pool is doing great: rethrows exceptions occurred during tasks execution, if any. More... | |
const ThreadIndex | maxAllowedWorkerCount (const PoolIndex pool=DEFAULT_POOL) const |
void | limitWorkerCount (ThreadIndex maxValue, const PoolIndex pool=DEFAULT_POOL) |
Limits maximum number of threads (workers) when performing tasks in a given pool. More... | |
void | setEventListener (EventListener *eventListener) |
Installs new event listener. More... | |
EventListener * | getEventListener () const |
Returns current event listener (or NULL) More... | |
bool | isGpuQueried () const |
bool | isGpuReady () const |
void | warmUpGpu () |
Initializes GPU within a given Context if not yet (takes no effect if it already is). More... | |
bool | queryGpuInfo (std::string &vendor, std::string &renderer) |
Initializes the GPU if not yet and queries information about it. More... | |
bool | isManagingThread () const |
GL::RecycleBin * | getGpuRecycleBin () const |
bool | operator== (const Context &context) const |
Context comparaison operator Two different instances of contexts are basically never identical; returning true only if the two point to the same instance. More... | |
Public Member Functions inherited from Beatmup::Object | |
virtual | ~Object () |
Static Public Attributes | |
static const PoolIndex | DEFAULT_POOL = 0 |
Private Member Functions | |
Context (const Context &)=delete | |
disabling copying constructor More... | |
Private Attributes | |
Impl * | impl |
GL::RecycleBin * | recycleBin |
stores GPU garbage: resources managed by GPU and might be freed in the managing thread only More... | |
Basic class: task and memory management, any kind of static data.
|
privatedelete |
disabling copying constructor
Context::Context | ( | ) |
Definition at line 226 of file context.cpp.
Context::Context | ( | const PoolIndex | numThreadPools | ) |
Definition at line 227 of file context.cpp.
Context::~Context | ( | ) |
Definition at line 233 of file context.cpp.
float Context::performTask | ( | AbstractTask & | task, |
const PoolIndex | pool = DEFAULT_POOL |
||
) |
Performs a given task.
task | The task |
pool | A thread pool to run the task in |
Definition at line 240 of file context.cpp.
void Context::repeatTask | ( | AbstractTask & | task, |
bool | abortCurrent, | ||
const PoolIndex | pool = DEFAULT_POOL |
||
) |
Ensures a given task executed at least once.
task | The task |
abortCurrent | if true and the same task is currently running, the abort signal is sent. |
pool | A thread pool to run the task in |
Definition at line 244 of file context.cpp.
Job Context::submitTask | ( | AbstractTask & | task, |
const PoolIndex | pool = DEFAULT_POOL |
||
) |
Adds a new task to the jobs queue.
task | The task |
pool | A thread pool to run the task in |
Definition at line 248 of file context.cpp.
Job Context::submitPersistentTask | ( | AbstractTask & | task, |
const PoolIndex | pool = DEFAULT_POOL |
||
) |
Adds a new persistent task to the jobs queue.
Persistent task is repeated until it decides itself to quit.
task | The task |
pool | A thread pool to run the task in |
Definition at line 252 of file context.cpp.
void Context::waitForJob | ( | Job | job, |
const PoolIndex | pool = DEFAULT_POOL |
||
) |
Waits until a given job finishes.
job | The job |
pool | Pool index |
Definition at line 256 of file context.cpp.
bool Context::abortJob | ( | Job | job, |
const PoolIndex | pool = DEFAULT_POOL |
||
) |
Aborts a given submitted job.
job | The job |
pool | Pool index |
true
if the job was interrupted while running. Definition at line 260 of file context.cpp.
void Context::wait | ( | const PoolIndex | pool = DEFAULT_POOL | ) |
Blocks until all the submitted jobs are executed.
pool | Pool index |
Definition at line 264 of file context.cpp.
bool Context::busy | ( | const PoolIndex | pool = DEFAULT_POOL | ) |
Queries whether a given thread pool is busy with a task.
pool | The thread pool to query |
true
if the thread pool is running a task, false
otherwise Definition at line 268 of file context.cpp.
void Context::check | ( | const PoolIndex | pool = DEFAULT_POOL | ) |
Checks if a specific thread pool is doing great: rethrows exceptions occurred during tasks execution, if any.
pool | The thread pool to query |
Definition at line 272 of file context.cpp.
const ThreadIndex Context::maxAllowedWorkerCount | ( | const PoolIndex | pool = DEFAULT_POOL | ) | const |
Definition at line 276 of file context.cpp.
void Context::limitWorkerCount | ( | ThreadIndex | maxValue, |
const PoolIndex | pool = DEFAULT_POOL |
||
) |
Limits maximum number of threads (workers) when performing tasks in a given pool.
maxValue | Number limiting the worker count |
pool | The thread pool |
Definition at line 280 of file context.cpp.
void Context::setEventListener | ( | EventListener * | eventListener | ) |
Installs new event listener.
Definition at line 284 of file context.cpp.
Context::EventListener * Context::getEventListener | ( | ) | const |
Returns current event listener (or NULL)
Definition at line 288 of file context.cpp.
bool Context::isGpuQueried | ( | ) | const |
bool Context::isGpuReady | ( | ) | const |
void Context::warmUpGpu | ( | ) |
Initializes GPU within a given Context if not yet (takes no effect if it already is).
GPU initialization may take some time and is done when a first task using GPU is being run. Warming up the GPU is useful to avoid the app get stucked for some time when it launches its first task on GPU.
Definition at line 300 of file context.cpp.
bool Context::queryGpuInfo | ( | std::string & | vendor, |
std::string & | renderer | ||
) |
Initializes the GPU if not yet and queries information about it.
[out] | vendor | GPU vendor string. |
[out] | renderer | renderer string. |
true
if a GPU is found. Definition at line 307 of file context.cpp.
bool Context::isManagingThread | ( | ) | const |
Definition at line 336 of file context.cpp.
GL::RecycleBin * Context::getGpuRecycleBin | ( | ) | const |
Definition at line 340 of file context.cpp.
|
inline |
|
private |