Пример #1
0
 public String describeWaitList() {
   StringBuilder sb = new StringBuilder(this + " waits for [");
   PrimitiveIntIterator iter = waitList.iterator();
   while (iter.hasNext()) {
     sb.append(iter.next()).append(", ");
   }
   sb.append("]");
   return sb.toString();
 }
Пример #2
0
 private void markAsWaitingFor(
     ForsetiLockManager.Lock lock, Locks.ResourceType type, long resourceId) {
   clearWaitList();
   lock.copyHolderWaitListsInto(waitList);
   if (lock.anyHolderIsWaitingFor(myId) && lock.holderWaitListSize() >= waitListSize()) {
     waitList.clear();
     throw new DeadlockDetectedException(
         this
             + " can't acquire "
             + lock
             + " on "
             + type
             + "("
             + resourceId
             + "), because holders of that lock "
             + "are waiting for "
             + this
             + ".\n Wait list:"
             + lock.describeWaitList());
   }
 }
Пример #3
0
 private void clearWaitList() {
   waitList.clear();
   waitList.put(myId);
 }
Пример #4
0
 public boolean isWaitingFor(int clientId) {
   // TODO Similarly to the above, make reading the waitList a volatile load.
   return clientId != myId && waitList.contains(clientId);
 }
Пример #5
0
 public void copyWaitListTo(SimpleBitSet other) {
   other.put(waitList);
   // TODO It might make sense to somehow put a StoreLoad barrier here,
   // TODO to expidite the observation of the updated waitList in other clients.
 }
Пример #6
0
 public int waitListSize() {
   return waitList.size();
 }