![]() |
VR-Forces 4.5 Class Documentation
|
Enables parallelism in the main thread. More...

Classes | |
| class | CallbackInterface |
| Interface for defining callbacks. More... | |
Public Types | |
| enum | AccessType { EXCLUSIVE, SHARED, UNLOCKED } |
| typedef boost::unordered_map < std::string, bool > | EnabledMap |
Public Member Functions | |
| DtParallelTickManager (DtVrfSimOptionsInterface *options) | |
| virtual | ~DtParallelTickManager () |
| virtual void | setCallbackQueue (DtVrfCallbackQueue *) |
| Takes ownership. | |
| virtual DtVrfCallbackQueue * | queue () const |
| Access the callback queue object. | |
| virtual bool | enabled (const std::string &, bool def) const |
| Simple mechanism for controlling multiple parallel sections. | |
| virtual bool | executeCommand (const std::string &, bool on) |
| Execute a console command. | |
| virtual void | printInfo (std::ostream &) const |
| Print information about current state. | |
| virtual ThreadLocalInfo & | threadLocalInfo () |
| ThreadLocalInfo (DtParallelTickManager *m) | |
| DtParallelTickManager::AccessType | state () const |
| virtual void | flushQueue (bool useThisThread) |
| Wait for all queued tasks to complete This function is called when you have added a bunch of tasks to the queue and need to make sure they are finished before proceeding. | |
| virtual void | flushQueue () |
| virtual bool | mainThreadWait () const |
| Accessor/mutator for main thread participation in running callbacks. | |
| virtual void | setMainThreadWait (bool) |
| virtual bool | active () const |
| Accessorm/mutator for the entire parallel mechanism. | |
| virtual void | setActive (bool) |
| virtual void | addCallback (CallbackInterface *, bool runNow=false) |
| Add callbacks to the queue. | |
| virtual void | addCallback (CallbackInterface &, bool runNow=false) |
| virtual void | addCallback (CallbackInterface *, const std::string &tag, bool def=true) |
| virtual void | addCallback (CallbackInterface &, const std::string &tag, bool def=true) |
| void | addCallback (CallbackInterface *, const char *tag, bool def=true) |
| void | addCallback (CallbackInterface &, const char *tag, bool def=true) |
| template<typename Container > | |
| void | addCallbacks (Container &cont, bool runNow=false) |
| template<typename Container > | |
| void | addCallbacks (Container &cont, const std::string &tag, bool def=true) |
| template<typename Container > | |
| void | addCallbacks (Container &cont, const char *tag, bool def=true) |
| virtual void | lock () |
| Manipulate global mutex. | |
| virtual void | unlock () |
| virtual void | readLock () |
| virtual void | readUnlock () |
| virtual void | upgradeToWriter () |
| virtual void | downgradeToReader () |
| virtual void | changeAccess (AccessType from, AccessType to) |
Private Types | |
| typedef tbb::mutex | Mutex |
| typedef tbb::interface5::condition_variable | ConditionVariable |
| typedef tbb::interface5::unique_lock < Mutex > | ScopedLock |
| typedef tbb::cache_aligned_allocator < ThreadLocalInfo * > | ThreadLocalAllocator |
| typedef tbb::enumerable_thread_specific < ThreadLocalInfo *, ThreadLocalAllocator, tbb::ets_key_per_instance > | ThreadLocalContainer |
| DtCriticalSection, ThreadLocalAllocator> ThreadLocalContainer;. | |
| typedef std::vector < DtCriticalSection * > | Stack |
Private Member Functions | |
| virtual void | createCallbackQueue (bool force=false) |
| Create the callback queue. | |
| void | push (DtCriticalSection &cs) |
| void | pop (DtCriticalSection &cs) |
Friends | |
| class | DtCriticalSection |
Enables parallelism in the main thread.
This class wraps a mutex and a callback queue thread pool which are used to execute multiple functions in parallel in the sim main thread. The mutex protects the entire global state of VR-Forces.
There are two ways to execute a callback, normal (parallel) or serial. The normal method just executes the callback with no synchronization. If the callback needs to access any of the global VR-Forces state then it must use create a SerialScopeGuard around that section (just like a mutex scope lock). This will lock the global mutex and prevent any other threads from access the global state. The serial method locks the global mutex when the callback is called This means that all other threads accessing the global state will have to wait. A serial executed callback can use ParallelScopeGuard to unlock the global mutex around a section which does not access any global state.
By default DtVrfObjects are ticked in serial since they all access the global state. Individual actuators that have safe sections (like terrain intersections or feature queries) can then be modified as needed by inserting ParallelScopeGuards.
Users generally do not access this class directly, see DtCriticalSection.
| typedef boost::unordered_map<std::string, bool> DtParallelTickManager::EnabledMap |
|
private |
|
private |
|
private |
|
private |
|
private |
DtCriticalSection, ThreadLocalAllocator> ThreadLocalContainer;.
|
private |
|
explicit |
|
virtual |
|
virtual |
Takes ownership.
|
virtual |
Access the callback queue object.
|
virtual |
Wait for all queued tasks to complete This function is called when you have added a bunch of tasks to the queue and need to make sure they are finished before proceeding.
Whether the calling thread waits or participates in calling the callbacks is controlled by the useThisThread parameter or DtVrfSimOptionsInterface::flushCallbackQueueInMainThread if not supplied.
|
virtual |
|
virtual |
Accessor/mutator for main thread participation in running callbacks.
|
virtual |
|
virtual |
Accessorm/mutator for the entire parallel mechanism.
Disabling will delete the queue and execute callbacks in the calling thread.
|
virtual |
Simple mechanism for controlling multiple parallel sections.
This class is designed to be used by multiple sections of code to execute different sets of parallel callbacks. This function allows each of those sections to be named and then have their options controlled individually by this class. If you supply a tag in any of the add callback functions a record will be made of that that tag by this function.
| def | Default value to record if it's a new tag. |
Referenced by addCallbacks().
Execute a console command.
|
virtual |
Print information about current state.
|
virtual |
Add callbacks to the queue.
The pointer versions take ownership of their callbacks. The reference versions do not and require the caller to keep them alive. The container versions add an STL-like container of callbacks.
| runNow | Execute the callback right now instead of adding it the queue. |
| tag | See enabled(). |
| def | Default value for enabled(). |
Referenced by addCallbacks().
|
virtual |
|
virtual |
|
virtual |
| void DtParallelTickManager::addCallback | ( | CallbackInterface * | , |
| const char * | tag, | ||
| bool | def = true |
||
| ) |
| void DtParallelTickManager::addCallback | ( | CallbackInterface & | , |
| const char * | tag, | ||
| bool | def = true |
||
| ) |
|
inline |
References addCallback().
Referenced by addCallbacks().
|
inline |
References addCallback(), and enabled().
|
inline |
References addCallbacks().
|
virtual |
Manipulate global mutex.
|
virtual |
|
virtual |
|
virtual |
|
virtual |
|
virtual |
|
virtual |
|
virtual |
|
privatevirtual |
Create the callback queue.
|
explicit |
| DtParallelTickManager::AccessType DtParallelTickManager::state | ( | ) | const |
|
private |
|
private |
|
friend |
|
mutableprivate |
|
mutableprivate |
|
mutableprivate |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
mutableprivate |
|
private |
|
private |
|
private |
|
private |