![]() |
Gorgon Game Engine
|
Contains multi-threading functions and objects. More...
Functions | |
void | RunAsync (std::function< void()> fn) |
Executes a function asynchronously. More... | |
void | RunInParallel (std::function< void(int, int)> fn, unsigned threads=0) |
Runs a function specified amount of times in parallel. More... | |
Contains multi-threading functions and objects.
For thread and mutex
void Gorgon::Threading::RunAsync | ( | std::function< void()> | fn | ) |
Executes a function asynchronously.
This function starts the thread immediately. There is no way to wait for the thread, stop or query its execution.
fn | the function to be executed. |
void Gorgon::Threading::RunInParallel | ( | std::function< void(int, int)> | fn, |
unsigned | threads = 0 |
||
) |
Runs a function specified amount of times in parallel.
threads parameter controls the amount of parallel executions. This function will return when all threads it controls finishes. The following example performs an operation over the data vector using 4 threads. If the threads parameter is omitted, the number of threads supported by hardware is used.
fn | is the function to be executed. First parameter of the function should be thread id, second is the number of threads. See the example. |
threads | the number of threads to be executed. |