示例#1
0
文件: vrpn_Mutex.C 项目: Progga1/vrpn
vrpn_PeerMutex::~vrpn_PeerMutex (void) {

  // Send an explicit message so they know we're shutting down, not
  // just disconnecting temporarily and will be back.

  // Probably a safer way to do it would be to do addPeer and losePeer
  // implicitly through dropped_connection/got_connection on d_server
  // and d_peer?

  // There is no good solution!

  // Possible improvement:  if we lose our connection and regain it,
  // send some sort of announcement message to everybody who used to
  // be our peer so they add us back into their tables.

  if (isHeldLocally()) {
    release();
  }

  if (d_mutexName) {
    delete [] d_mutexName;
  }
  for (int i = 0; i < d_numPeers; ++i) {
    if (d_peer[i]) {
      d_peer[i]->removeReference();
    }
  }
  if (d_peer) {
    delete [] d_peer;
  }

  if (d_server) {
    d_server->removeReference();
  }
}
示例#2
0
文件: vrpn_Mutex.C 项目: ASPePeX/vrpn
void vrpn_PeerMutex::release(void)
{
    int i;

    // Can't release it if we don't already have it.
    // There aren't any appropriate callbacks to trigger here.  :)
    if (!isHeldLocally()) {

#ifdef VERBOSE
        fprintf(stderr, "vrpn_PeerMutex::release:  we don't hold the mutex.\n");
#endif

        return;
    }

    d_state = AVAILABLE;
    d_holderIP = 0;
    d_holderPort = -1;
    for (i = 0; i < d_numPeers; i++) {
        sendRelease(d_peer[i]);
    }

    triggerReleaseCallbacks();

#ifdef VERBOSE
    fprintf(stderr, "vrpn_PeerMutex::release:  released the mutex.\n");
#endif
}
示例#3
0
文件: vrpn_Mutex.C 项目: Progga1/vrpn
void vrpn_Mutex_Remote::release (void) {
  if (!isHeldLocally()) {
    return;
  }

#ifdef VERBOSE
  fprintf(stderr, "Releasing mutex.\n");
#endif

  d_state = AVAILABLE;
  sendRelease();
  triggerReleaseCallbacks();
}