#include <cartobase/thread/threadedLoop.h>
Definition at line 48 of file threadedLoop.h.
◆ ThreadedLoop()
carto::ThreadedLoop::ThreadedLoop |
( |
LoopContext * |
loopContext, |
|
|
int |
startIndex, |
|
|
int |
count, |
|
|
int |
maxThreadCount = 0 , |
|
|
float |
threadsByCpu = 1.0f |
|
) |
| |
◆ ~ThreadedLoop()
virtual carto::ThreadedLoop::~ThreadedLoop |
( |
| ) |
|
|
virtual |
◆ endThreadsWhenDone()
bool carto::ThreadedLoop::endThreadsWhenDone |
( |
| ) |
const |
The loop can work in two modes: single run (endThreadsWhenDone() is true) or multiple runs (endThreadsWhenDone is false).
- In single run mode, launch() creates the needed number of threads, runs them to complete the loop, then destroys every thread.
- In multiple runs mode, the first call to launch() creates the needed threads, but doesn't destroy them after the loop is finished. Each thread stays alive and blocks on a semaphore. When you call launch() again later for another run (possibly after changing the LoopContext), the existing threads will be re-used for the next loop, so the cost of destroying and creating threads again is avoided. All threads will be actually destroyed when the ThreadedLoop is deleted.
◆ launch()
bool carto::ThreadedLoop::launch |
( |
bool |
resetGauge = true , |
|
|
bool |
resetCancel = true |
|
) |
| |
run the loop to the end until all iterations are finished
◆ run()
void carto::ThreadedLoop::run |
( |
| ) |
|
run one iteration step. It normally calls the LoopContext diIt() method
◆ runSingleThreaded()
bool carto::ThreadedLoop::runSingleThreaded |
( |
bool |
resetGauge = true , |
|
|
bool |
resetCancel = true |
|
) |
| |
◆ setEndThreadsWhenDone()
void carto::ThreadedLoop::setEndThreadsWhenDone |
( |
bool |
x | ) |
|
Warning: it's possibly not safe to change this value from false to true after launch() has been called.
◆ setLoopContext()
void carto::ThreadedLoop::setLoopContext |
( |
LoopContext * |
| ) |
|
This function is only useful in multiple run mode (endThreadsWhenDone false).
Call it only between two runs, from the control thread (the thread running the loop).
◆ setLoopCount()
void carto::ThreadedLoop::setLoopCount |
( |
int |
n | ) |
|
The documentation for this class was generated from the following file: