Esempio n. 1
0
 /** Execute the given command directly in the current thread, within the supplied lock. */
 public void execute(Runnable command) throws InterruptedException {
   mutex_.acquire();
   try {
     command.run();
   } finally {
     mutex_.release();
   }
 }
Esempio n. 2
0
 /** Try to acquire sync before a reader operation; record failure * */
 protected boolean beforeRead() {
   try {
     rd_.acquire();
     return false;
   } catch (InterruptedException ex) {
     syncFailures_.increment();
     return true;
   }
 }
Esempio n. 3
0
 public void clear() {
   try {
     wr_.acquire();
     try {
       c_.clear();
     } finally {
       wr_.release();
     }
   } catch (InterruptedException ex) {
     Thread.currentThread().interrupt();
     throw new UnsupportedOperationException();
   }
 }
Esempio n. 4
0
 public Object remove(Object key) {
   try {
     wr_.acquire();
     try {
       return c_.remove(key);
     } finally {
       wr_.release();
     }
   } catch (InterruptedException ex) {
     Thread.currentThread().interrupt();
     throw new UnsupportedOperationException();
   }
 }
Esempio n. 5
0
 public void lock() {
   sync.acquire(1);
 }
Esempio n. 6
0
 @Override
 public void lock() {
   sync.acquire(1);
 }