vrpn 07.35
Virtual Reality Peripheral Network
|
#include <vrpn_Mutex.h>
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. | |
![]() | |
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) |
![]() | |
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 |
mutexCallback * | d_reqGrantedCB |
mutexCallback * | d_reqDeniedCB |
mutexCallback * | d_takeCB |
mutexCallback * | d_releaseCB |
![]() | |
vrpn_Connection * | d_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 |
Definition at line 70 of file vrpn_Mutex.h.
|
protected |
Enumerator | |
---|---|
OURS | |
REQUESTING | |
AVAILABLE | |
HELD_REMOTELY |
Definition at line 114 of file vrpn_Mutex.h.
vrpn_Mutex_Remote::vrpn_Mutex_Remote | ( | const char * | name, |
vrpn_Connection * | c = NULL |
||
) |
Definition at line 372 of file vrpn_Mutex.C.
References vrpn_Connection::connected(), vrpn_Mutex::d_connection, vrpn_Mutex::d_denyRequest_type, vrpn_Mutex::d_grantRequest_type, vrpn_Mutex::d_initialize_type, vrpn_Mutex::d_releaseNotification_type, handle_denyRequest(), handle_gotConnection(), handle_grantRequest(), handle_initialize(), handle_releaseNotification(), vrpn_Connection::register_handler(), vrpn_Connection::register_message_type(), requestIndex(), and vrpn_got_connection.
|
virtual |
Definition at line 404 of file vrpn_Mutex.C.
References vrpn_Mutex::d_connection, vrpn_Mutex::d_denyRequest_type, vrpn_Mutex::d_grantRequest_type, vrpn_Mutex::d_initialize_type, vrpn_Mutex::d_releaseNotification_type, handle_denyRequest(), handle_gotConnection(), handle_grantRequest(), handle_initialize(), handle_releaseNotification(), vrpn_Connection::register_message_type(), release(), vrpn_Connection::unregister_handler(), and vrpn_got_connection.
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.
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.
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.
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.
|
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().
|
staticprotected |
Definition at line 714 of file vrpn_Mutex.C.
References d_myIndex, and requestIndex().
Referenced by vrpn_Mutex_Remote(), and ~vrpn_Mutex_Remote().
|
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().
|
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().
|
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().
vrpn_bool vrpn_Mutex_Remote::isAvailable | ( | void | ) | const |
vrpn_bool vrpn_Mutex_Remote::isHeldLocally | ( | void | ) | const |
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.
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().
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().
|
protected |
Definition at line 440 of file vrpn_Mutex.C.
References vrpn_Mutex::d_connection, vrpn_Mutex::d_myId, vrpn_Mutex::d_requestIndex_type, vrpn_Connection::pack_message(), vrpn_buffer(), vrpn_CONNECTION_RELIABLE, and vrpn_gettimeofday.
Referenced by handle_gotConnection(), and vrpn_Mutex_Remote().
|
protected |
Definition at line 733 of file vrpn_Mutex.C.
References d_reqDeniedCB, vrpn_Mutex_Remote::mutexCallback::f, vrpn_Mutex_Remote::mutexCallback::next, and vrpn_Mutex_Remote::mutexCallback::userdata.
Referenced by handle_denyRequest(), and request().
|
protected |
Definition at line 723 of file vrpn_Mutex.C.
References d_reqGrantedCB, vrpn_Mutex_Remote::mutexCallback::f, vrpn_Mutex_Remote::mutexCallback::next, and vrpn_Mutex_Remote::mutexCallback::userdata.
Referenced by handle_grantRequest().
|
protected |
Definition at line 753 of file vrpn_Mutex.C.
References d_releaseCB, vrpn_Mutex_Remote::mutexCallback::f, vrpn_Mutex_Remote::mutexCallback::next, and vrpn_Mutex_Remote::mutexCallback::userdata.
Referenced by handle_releaseNotification(), and release().
|
protected |
Definition at line 743 of file vrpn_Mutex.C.
References d_takeCB, vrpn_Mutex_Remote::mutexCallback::f, vrpn_Mutex_Remote::mutexCallback::next, and vrpn_Mutex_Remote::mutexCallback::userdata.
Referenced by handle_grantRequest().
|
protected |
Definition at line 117 of file vrpn_Mutex.h.
Referenced by handle_denyRequest(), handle_gotConnection(), handle_grantRequest(), handle_initialize(), and request().
|
protected |
Definition at line 143 of file vrpn_Mutex.h.
Referenced by addReleaseCallback(), and triggerReleaseCallbacks().
|
protected |
Definition at line 141 of file vrpn_Mutex.h.
Referenced by addRequestDeniedCallback(), and triggerDenyCallbacks().
|
protected |
Definition at line 140 of file vrpn_Mutex.h.
Referenced by addRequestGrantedCallback(), and triggerGrantCallbacks().
|
protected |
Definition at line 118 of file vrpn_Mutex.h.
Referenced by handle_initialize(), and request().
|
protected |
Definition at line 116 of file vrpn_Mutex.h.
Referenced by handle_denyRequest(), handle_grantRequest(), handle_releaseNotification(), isAvailable(), isHeldLocally(), isHeldRemotely(), release(), and request().
|
protected |
Definition at line 142 of file vrpn_Mutex.h.
Referenced by addTakeCallback(), and triggerTakeCallbacks().