예제 #1
0
 @Override
 public Lockable atomic(Lockable old) {
   _old = old;
   if (old != null) { // Prior Lockable exists?
     assert !old.is_wlocked(_job_key)
         : "Key "
             + _key
             + " already locked; lks="
             + Arrays.toString(old._lockers); // No double locking by same job
     if (old.is_locked(_job_key)) // read-locked by self? (double-write-lock checked above)
     old.set_unlocked(
           old._lockers, _job_key); // Remove read-lock; will atomically upgrade to write-lock
     if (!old.is_unlocked()) // Blocking for some other Job to finish???
     throw new IllegalArgumentException(
           old.errStr()
               + " "
               + _key
               + " is already in use.  Unable to use it now.  Consider using a different destination name.");
     assert old.is_unlocked()
         : "Not unlocked when locking " + Arrays.toString(old._lockers) + " for " + _job_key;
   }
   // Update & set the new value
   set_write_lock(_job_key);
   return Lockable.this;
 }
예제 #2
0
 @Override
 public Lockable atomic(Lockable old) {
   assert old.is_locked(_job_key);
   set_unlocked(old._lockers, _job_key);
   return Lockable.this;
 }