vrpn 07.35
Virtual Reality Peripheral Network
Loading...
Searching...
No Matches
vrpn_Mutex_Remote Class Reference

#include <vrpn_Mutex.h>

Inheritance diagram for vrpn_Mutex_Remote:
Collaboration diagram for vrpn_Mutex_Remote:

Classes

struct  mutexCallback
 

Public Member Functions

 vrpn_Mutex_Remote (const char *name, vrpn_Connection *=NULL)
 
virtual ~vrpn_Mutex_Remote (void)
 
vrpn_bool isAvailable (void) const
 True from when release() is called or we receive a release message from another process until request() is called or we grant the lock to another process in response to its request message.
 
vrpn_bool isHeldLocally (void) const
 True from when RequestGranted callbacks are triggered until release() is called.
 
vrpn_bool isHeldRemotely (void) const
 True from when we grant the lock to another process in response to its request message until we receive a release message from another process.
 
void request (void)
 Request the distributed lock. Does not request the lock if !isAvailable(), instead automatically triggering DeniedCallbacks.
 
void release (void)
 Release the distributed lock. Does nothing if !isHeldLocally() and there isn't a request pending.
 
vrpn_bool addRequestGrantedCallback (void *userdata, int(*)(void *))
 These callbacks are triggered when OUR request is granted.
 
vrpn_bool addRequestDeniedCallback (void *userdata, int(*)(void *))
 These callbacks are triggered when OUR request is denied.
 
vrpn_bool addTakeCallback (void *userdata, int(*)(void *))
 These callbacks are triggered when ANY peer gets the mutex.
 
vrpn_bool addReleaseCallback (void *userdata, int(*)(void *))
 These callbacks are triggered when ANY peer releases the mutex.
 
- Public Member Functions inherited from vrpn_Mutex
 vrpn_Mutex (const char *name, vrpn_Connection *=NULL)
 
virtual ~vrpn_Mutex (void)=0
 
void mainloop (void)
 

Protected Types

enum  state { OURS , REQUESTING , AVAILABLE , HELD_REMOTELY }
 

Protected Member Functions

void requestIndex (void)
 
void triggerGrantCallbacks (void)
 
void triggerDenyCallbacks (void)
 
void triggerTakeCallbacks (void)
 
void triggerReleaseCallbacks (void)
 
- Protected Member Functions inherited from vrpn_Mutex
void sendRequest (vrpn_int32 index)
 
void sendRelease (void)
 
void sendReleaseNotification (void)
 
void sendGrantRequest (vrpn_int32 index)
 
void sendDenyRequest (vrpn_int32 index)
 

Static Protected Member Functions

static int VRPN_CALLBACK handle_grantRequest (void *, vrpn_HANDLERPARAM)
 
static int VRPN_CALLBACK handle_denyRequest (void *, vrpn_HANDLERPARAM)
 
static int VRPN_CALLBACK handle_releaseNotification (void *, vrpn_HANDLERPARAM)
 
static int VRPN_CALLBACK handle_initialize (void *, vrpn_HANDLERPARAM)
 
static int VRPN_CALLBACK handle_gotConnection (void *, vrpn_HANDLERPARAM)
 

Protected Attributes

state d_state
 
vrpn_int32 d_myIndex
 
vrpn_bool d_requestBeforeInit
 
mutexCallbackd_reqGrantedCB
 
mutexCallbackd_reqDeniedCB
 
mutexCallbackd_takeCB
 
mutexCallbackd_releaseCB
 
- Protected Attributes inherited from vrpn_Mutex
vrpn_Connectiond_connection
 
vrpn_int32 d_myId
 
vrpn_int32 d_requestIndex_type
 
vrpn_int32 d_requestMutex_type
 
vrpn_int32 d_release_type
 
vrpn_int32 d_releaseNotification_type
 
vrpn_int32 d_grantRequest_type
 
vrpn_int32 d_denyRequest_type
 
vrpn_int32 d_initialize_type
 

Detailed Description

Definition at line 70 of file vrpn_Mutex.h.

Member Enumeration Documentation

◆ state

enum vrpn_Mutex_Remote::state
protected
Enumerator
OURS 
REQUESTING 
AVAILABLE 
HELD_REMOTELY 

Definition at line 114 of file vrpn_Mutex.h.

Constructor & Destructor Documentation

◆ vrpn_Mutex_Remote()

◆ ~vrpn_Mutex_Remote()

Member Function Documentation

◆ addReleaseCallback()

vrpn_bool vrpn_Mutex_Remote::addReleaseCallback ( void *  userdata,
int(*)(void *)  f 
)

These callbacks are triggered when ANY peer releases the mutex.

Definition at line 569 of file vrpn_Mutex.C.

References d_releaseCB, vrpn_Mutex_Remote::mutexCallback::f, vrpn_Mutex_Remote::mutexCallback::next, and vrpn_Mutex_Remote::mutexCallback::userdata.

◆ addRequestDeniedCallback()

vrpn_bool vrpn_Mutex_Remote::addRequestDeniedCallback ( void *  userdata,
int(*)(void *)  f 
)

These callbacks are triggered when OUR request is denied.

Definition at line 533 of file vrpn_Mutex.C.

References d_reqDeniedCB, vrpn_Mutex_Remote::mutexCallback::f, vrpn_Mutex_Remote::mutexCallback::next, and vrpn_Mutex_Remote::mutexCallback::userdata.

◆ addRequestGrantedCallback()

vrpn_bool vrpn_Mutex_Remote::addRequestGrantedCallback ( void *  userdata,
int(*)(void *)  f 
)

These callbacks are triggered when OUR request is granted.

Definition at line 515 of file vrpn_Mutex.C.

References d_reqGrantedCB, vrpn_Mutex_Remote::mutexCallback::f, vrpn_Mutex_Remote::mutexCallback::next, and vrpn_Mutex_Remote::mutexCallback::userdata.

◆ addTakeCallback()

vrpn_bool vrpn_Mutex_Remote::addTakeCallback ( void *  userdata,
int(*)(void *)  f 
)

These callbacks are triggered when ANY peer gets the mutex.

Definition at line 551 of file vrpn_Mutex.C.

References d_takeCB, vrpn_Mutex_Remote::mutexCallback::f, vrpn_Mutex_Remote::mutexCallback::next, and vrpn_Mutex_Remote::mutexCallback::userdata.

◆ handle_denyRequest()

int vrpn_Mutex_Remote::handle_denyRequest ( void *  userdata,
vrpn_HANDLERPARAM  p 
)
staticprotected

Definition at line 613 of file vrpn_Mutex.C.

References vrpn_HANDLERPARAM::buffer, d_myIndex, d_state, HELD_REMOTELY, triggerDenyCallbacks(), and vrpn_unbuffer().

Referenced by vrpn_Mutex_Remote(), and ~vrpn_Mutex_Remote().

Here is the call graph for this function:

◆ handle_gotConnection()

int vrpn_Mutex_Remote::handle_gotConnection ( void *  userdata,
vrpn_HANDLERPARAM   
)
staticprotected

Definition at line 714 of file vrpn_Mutex.C.

References d_myIndex, and requestIndex().

Referenced by vrpn_Mutex_Remote(), and ~vrpn_Mutex_Remote().

Here is the call graph for this function:

◆ handle_grantRequest()

int vrpn_Mutex_Remote::handle_grantRequest ( void *  userdata,
vrpn_HANDLERPARAM  p 
)
staticprotected

Definition at line 587 of file vrpn_Mutex.C.

References vrpn_HANDLERPARAM::buffer, d_myIndex, d_state, HELD_REMOTELY, OURS, triggerGrantCallbacks(), triggerTakeCallbacks(), and vrpn_unbuffer().

Referenced by vrpn_Mutex_Remote(), and ~vrpn_Mutex_Remote().

Here is the call graph for this function:

◆ handle_initialize()

int vrpn_Mutex_Remote::handle_initialize ( void *  userdata,
vrpn_HANDLERPARAM  p 
)
staticprotected

Definition at line 652 of file vrpn_Mutex.C.

References vrpn_HANDLERPARAM::buffer, d_myIndex, d_requestBeforeInit, vrpn_HANDLERPARAM::payload_len, request(), and vrpn_unbuffer().

Referenced by vrpn_Mutex_Remote(), and ~vrpn_Mutex_Remote().

Here is the call graph for this function:

◆ handle_releaseNotification()

int vrpn_Mutex_Remote::handle_releaseNotification ( void *  userdata,
vrpn_HANDLERPARAM   
)
staticprotected

Definition at line 636 of file vrpn_Mutex.C.

References AVAILABLE, d_state, and triggerReleaseCallbacks().

Referenced by vrpn_Mutex_Remote(), and ~vrpn_Mutex_Remote().

Here is the call graph for this function:

◆ isAvailable()

vrpn_bool vrpn_Mutex_Remote::isAvailable ( void  ) const

True from when release() is called or we receive a release message from another process until request() is called or we grant the lock to another process in response to its request message.

Definition at line 425 of file vrpn_Mutex.C.

References AVAILABLE, and d_state.

Referenced by request().

◆ isHeldLocally()

vrpn_bool vrpn_Mutex_Remote::isHeldLocally ( void  ) const

True from when RequestGranted callbacks are triggered until release() is called.

Definition at line 430 of file vrpn_Mutex.C.

References d_state, and OURS.

Referenced by release().

◆ isHeldRemotely()

vrpn_bool vrpn_Mutex_Remote::isHeldRemotely ( void  ) const

True from when we grant the lock to another process in response to its request message until we receive a release message from another process.

Definition at line 435 of file vrpn_Mutex.C.

References d_state, and HELD_REMOTELY.

◆ release()

void vrpn_Mutex_Remote::release ( void  )

Release the distributed lock. Does nothing if !isHeldLocally() and there isn't a request pending.

Definition at line 500 of file vrpn_Mutex.C.

References AVAILABLE, d_state, isHeldLocally(), vrpn_Mutex::sendRelease(), and triggerReleaseCallbacks().

Referenced by ~vrpn_Mutex_Remote().

Here is the call graph for this function:

◆ request()

void vrpn_Mutex_Remote::request ( void  )

Request the distributed lock. Does not request the lock if !isAvailable(), instead automatically triggering DeniedCallbacks.

Definition at line 472 of file vrpn_Mutex.C.

References d_myIndex, d_requestBeforeInit, d_state, isAvailable(), REQUESTING, vrpn_Mutex::sendRequest(), and triggerDenyCallbacks().

Referenced by handle_initialize().

Here is the call graph for this function:

◆ requestIndex()

void vrpn_Mutex_Remote::requestIndex ( void  )
protected

◆ triggerDenyCallbacks()

void vrpn_Mutex_Remote::triggerDenyCallbacks ( void  )
protected

◆ triggerGrantCallbacks()

void vrpn_Mutex_Remote::triggerGrantCallbacks ( void  )
protected

◆ triggerReleaseCallbacks()

void vrpn_Mutex_Remote::triggerReleaseCallbacks ( void  )
protected

◆ triggerTakeCallbacks()

void vrpn_Mutex_Remote::triggerTakeCallbacks ( void  )
protected

Member Data Documentation

◆ d_myIndex

vrpn_int32 vrpn_Mutex_Remote::d_myIndex
protected

◆ d_releaseCB

mutexCallback* vrpn_Mutex_Remote::d_releaseCB
protected

Definition at line 143 of file vrpn_Mutex.h.

Referenced by addReleaseCallback(), and triggerReleaseCallbacks().

◆ d_reqDeniedCB

mutexCallback* vrpn_Mutex_Remote::d_reqDeniedCB
protected

Definition at line 141 of file vrpn_Mutex.h.

Referenced by addRequestDeniedCallback(), and triggerDenyCallbacks().

◆ d_reqGrantedCB

mutexCallback* vrpn_Mutex_Remote::d_reqGrantedCB
protected

Definition at line 140 of file vrpn_Mutex.h.

Referenced by addRequestGrantedCallback(), and triggerGrantCallbacks().

◆ d_requestBeforeInit

vrpn_bool vrpn_Mutex_Remote::d_requestBeforeInit
protected

Definition at line 118 of file vrpn_Mutex.h.

Referenced by handle_initialize(), and request().

◆ d_state

state vrpn_Mutex_Remote::d_state
protected

◆ d_takeCB

mutexCallback* vrpn_Mutex_Remote::d_takeCB
protected

Definition at line 142 of file vrpn_Mutex.h.

Referenced by addTakeCallback(), and triggerTakeCallbacks().


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