示例#1
0
 protected void updateLock(final String semaphoreID, final long remainingMS) {
   HashMap<String, Long> currentTimeouts, newTimeouts;
   do {
     currentTimeouts = MYMETHODTIMEOUTS.getValue(myAgent.getState());
     newTimeouts = new HashMap<String, Long>(currentTimeouts);
     newTimeouts.put(
         semaphoreID,
         remainingMS <= 0L ? Long.valueOf(0L) : System.currentTimeMillis() + remainingMS);
   } while (!MYMETHODTIMEOUTS.putValueIfUnchanged(
       myAgent.getState(), newTimeouts, currentTimeouts));
 }
示例#2
0
 @Override
 public long getLockMillisRemaining(final String semaphoreID) {
   final Long timeout = MYMETHODTIMEOUTS.getValue(myAgent.getState()).get(semaphoreID);
   return timeout == null ? -1L : timeout.longValue() - System.currentTimeMillis();
 }