OpenFrames
Public Types | Public Member Functions | Protected Attributes | List of all members
OpenFrames::FrameManager Class Reference

This class allows priority access to a ReferenceFrame heirarchy. More...

#include <FrameManager.hpp>

Inheritance diagram for OpenFrames::FrameManager:

Public Types

enum  Priority { LOW_PRIORITY, HIGH_PRIORITY }
 

Public Member Functions

 FrameManager (ReferenceFrame *frame=NULL)
 
void setFrame (ReferenceFrame *frame)
 
ReferenceFramegetFrame ()
 
osg::Group * getData ()
 
int lock (Priority priority=HIGH_PRIORITY)
 
int unlock (Priority priority=HIGH_PRIORITY)
 Users must specify the same priority as they did for lock/trylock.
 
int trylock (Priority priority=HIGH_PRIORITY)
 

Protected Attributes

osg::ref_ptr< ReferenceFrame_frame
 
OpenThreads::Mutex _mutexData
 
OpenThreads::Mutex _mutexNext
 
OpenThreads::Mutex _mutexLP
 

Detailed Description

This class allows priority access to a ReferenceFrame heirarchy.

This class allows multiple clients to synchronize access to a ReferenceFrame heirarchy, but allows high-priority clients access before low-priority clients. This avoids the case where high-fps rendering threads can hog the lock on certain OS's, and significantly delay the user trying to acquire the lock. To use: threads that frequently acquire the lock (e.g. rendering threads) should use low priority, and threads that need to make one-off changes to the scene graph (e.g. the user) should use high priority. NOTE: Implements "triple mutex" approach documented in: https://stackoverflow.com/questions/11666610/how-to-give-priority-to-privileged-thread-in-mutex-locking Approach summary: Data mutex D, Next-access mutex N, low-priority mutex L Low-priority Thread: lock L -> lock N -> lock D -> unlock N -> (...work...) -> unlock D -> unlock L High-priority Thread: lock N -> lock D -> unlock N -> (...work...) -> unlock D.


The documentation for this class was generated from the following file: