Esempio n. 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));
 }
Esempio n. 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();
 }