Exemple #1
0
 protected void handleSignalRequest(Request req) {
   Lock lock = _getLock(req.lock_name);
   lock.lock();
   try {
     ServerLock server_lock = server_locks.get(req.lock_name);
     if (server_lock != null) server_lock.handleRequest(req);
     else
       log.error(
           "Condition signal was received but lock was not created.  Couldn't notify anyone.");
   } finally {
     lock.unlock();
   }
 }
Exemple #2
0
 protected void handleLockRequest(Request req) {
   Lock lock = _getLock(req.lock_name);
   lock.lock();
   try {
     ServerLock server_lock = server_locks.get(req.lock_name);
     if (server_lock == null) {
       server_lock = new ServerLock(req.lock_name);
       ServerLock tmp = server_locks.putIfAbsent(req.lock_name, server_lock);
       if (tmp != null) server_lock = tmp;
       else {
         notifyLockCreated(req.lock_name);
       }
     }
     server_lock.handleRequest(req);
     if (server_lock.isEmpty()
         && server_lock.current_owner == null
         && server_lock.condition.queue.isEmpty()) {
       server_locks.remove(req.lock_name);
     }
   } finally {
     lock.unlock();
   }
 }