H3D API  2.4.1
Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | List of all members
H3D::ThreadSafeSField< BaseField > Class Template Reference

<> More...

#include <H3D/ThreadSafeFields.h>

Inheritance diagram for H3D::ThreadSafeSField< BaseField >:
Inheritance graph

Public Member Functions

 ThreadSafeSField ()
 Constructor.
 
virtual void setValue (const typename BaseField::value_type &v, int id=0)
 Set the value of the field.
 
virtual const BaseField::value_type & getValue (int id=0)
 Get the value of the field.
 
virtual void upToDate ()
 Make sure that the field is up-to-date. More...
 
- Public Member Functions inherited from H3D::PeriodicUpdate< BaseField >
 PeriodicUpdate (H3DFloat _period=0, PeriodType _period_type=COUNT)
 Constructor.
 
 ~PeriodicUpdate ()
 Destructor.
 
virtual bool timeToUpdate ()
 Determines if it is time to check that the field is updated. More...
 
void setPeriodType (PeriodType type)
 Set the type of the period.
 
void setPeriod (H3DFloat _period)
 Set the period for the update.
 
- Public Member Functions inherited from H3D::PeriodicUpdateField
virtual ~PeriodicUpdateField ()
 Destructor.
 

Protected Member Functions

virtual void update ()
 The update function is specialized to synchronize with the haptics threads and copy the new value of the field to the rt_value member in a thread safe way.
 

Static Protected Member Functions

static H3DUtil::PeriodicThread::CallbackCode transferValue (void *_data)
 Callback function to transfer copy a value between two pointers of the same type.
 

Protected Attributes

BaseField::value_type rt_value
 The copy of the field value to be used in the haptics threads.
 
bool rt_value_changed
 Flag indicating if the rt_value has been changed by a haptics thread.
 
- Protected Attributes inherited from H3D::PeriodicUpdate< BaseField >
PeriodType period_type
 The tye of the period.
 
H3DFloat period
 The period of automatic updates/.
 
TimeStamp last_up_to_date
 The time of the last call to upToDate.
 
unsigned int counter
 The number of calls to timeToUpdate() since the last update.
 

Additional Inherited Members

- Public Types inherited from H3D::PeriodicUpdate< BaseField >
enum  PeriodType
 Type defining how the period should be interpreted.
 

Detailed Description

template<class BaseField>
class H3D::ThreadSafeSField< BaseField >

<>

A template modifier to add thread safety to an SField type. The field network should never be accessed from anything else than the main thread. Often though values provided by fields control behaviour of things happening in the haptic threads. Therefore separate copies of the field values have to be maintained for usage in the haptics thread. This field template modifies a normal SField class to contain such a copy. The getValue() and setValue() functions can then be used by both the haptics thread and the main thread and depending on from which thread it is called the copy or the field value is returned. Once per scene-graph loop it is checked whether either the copy or the field network value has changed since last loop and if it has the values are updated in a thread safe manner to contain the same value.

Member Function Documentation

◆ upToDate()

template<class BaseField >
virtual void H3D::ThreadSafeSField< BaseField >::upToDate ( )
inlinevirtual

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