vrpn  07.33
Virtual Reality Peripheral Network
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. More...
 
vrpn_bool isHeldLocally (void) const
 True from when RequestGranted callbacks are triggered until < release() is called. More...
 
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. More...
 
void request (void)
 Request the distributed lock. Does not request the lock < if !isAvailable(), instead automatically triggering DeniedCallbacks. More...
 
void release (void)
 Release the distributed lock. Does nothing if !isHeldLocally() < and there isn't a request pending. More...
 
void addRequestGrantedCallback (void *userdata, int(*)(void *))
 These callbacks are triggered when OUR request is granted. More...
 
void addRequestDeniedCallback (void *userdata, int(*)(void *))
 These callbacks are triggered when OUR request is denied. More...
 
void addTakeCallback (void *userdata, int(*)(void *))
 These callbacks are triggered when ANY peer gets the mutex. More...
 
void addReleaseCallback (void *userdata, int(*)(void *))
 These callbacks are triggered when ANY peer releases the < mutex. More...
 
- 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

enum vrpn_Mutex_Remote::state
protected
Enumerator
OURS 
REQUESTING 
AVAILABLE 
HELD_REMOTELY 

Definition at line 114 of file vrpn_Mutex.h.

Constructor & Destructor Documentation

Member Function Documentation

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

These callbacks are triggered when ANY peer releases the < mutex.

Definition at line 544 of file vrpn_Mutex.C.

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

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

These callbacks are triggered when OUR request is denied.

Definition at line 512 of file vrpn_Mutex.C.

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

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

These callbacks are triggered when OUR request is granted.

Definition at line 496 of file vrpn_Mutex.C.

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

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

These callbacks are triggered when ANY peer gets the mutex.

Definition at line 528 of file vrpn_Mutex.C.

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

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

Definition at line 586 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:

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

Definition at line 687 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:

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

Definition at line 560 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:

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

Definition at line 625 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:

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

Definition at line 609 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:

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 413 of file vrpn_Mutex.C.

References AVAILABLE, and d_state.

Referenced by request().

vrpn_bool vrpn_Mutex_Remote::isHeldLocally ( void  ) const

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

Definition at line 418 of file vrpn_Mutex.C.

References d_state, and OURS.

Referenced by release().

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 423 of file vrpn_Mutex.C.

References d_state, and HELD_REMOTELY.

void vrpn_Mutex_Remote::release ( void  )

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

Definition at line 481 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:

void vrpn_Mutex_Remote::request ( void  )

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

Definition at line 453 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:

void vrpn_Mutex_Remote::requestIndex ( void  )
protected
void vrpn_Mutex_Remote::triggerDenyCallbacks ( void  )
protected
void vrpn_Mutex_Remote::triggerGrantCallbacks ( void  )
protected
void vrpn_Mutex_Remote::triggerReleaseCallbacks ( void  )
protected
void vrpn_Mutex_Remote::triggerTakeCallbacks ( void  )
protected

Member Data Documentation

vrpn_int32 vrpn_Mutex_Remote::d_myIndex
protected
mutexCallback* vrpn_Mutex_Remote::d_releaseCB
protected

Definition at line 143 of file vrpn_Mutex.h.

Referenced by addReleaseCallback(), and triggerReleaseCallbacks().

mutexCallback* vrpn_Mutex_Remote::d_reqDeniedCB
protected

Definition at line 141 of file vrpn_Mutex.h.

Referenced by addRequestDeniedCallback(), and triggerDenyCallbacks().

mutexCallback* vrpn_Mutex_Remote::d_reqGrantedCB
protected

Definition at line 140 of file vrpn_Mutex.h.

Referenced by addRequestGrantedCallback(), and triggerGrantCallbacks().

vrpn_bool vrpn_Mutex_Remote::d_requestBeforeInit
protected

Definition at line 118 of file vrpn_Mutex.h.

Referenced by handle_initialize(), and request().

state vrpn_Mutex_Remote::d_state
protected
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: