Package java.util.concurrent.locks

Examples of java.util.concurrent.locks.ReentrantReadWriteLock


      lock.writeLock().lock();
   }

   public void testOneWriterMultipleReaders() throws InterruptedException
   {
      lock = new ReentrantReadWriteLock();

      Writer writer = new Writer("writer");
      Reader reader1 = new Reader("reader1");
      Reader reader2 = new Reader("reader2");
View Full Code Here


      lockSegmentShift = 32 - tempLockSegShift;
      lockSegmentMask = numLocks - 1;

      sharedLocks = new ReentrantReadWriteLock[numLocks];

      for (int i = 0; i < numLocks; i++) sharedLocks[i] = new ReentrantReadWriteLock();
   }
View Full Code Here

    * @param fqn       the Fqn to lock on
    * @param exclusive if true, a write (exclusive) lock is attempted, otherwise a read (shared) lock is used.
    */
   public void acquireLock(Fqn fqn, boolean exclusive)
   {
      ReentrantReadWriteLock lock = getLock(fqn);

      if (exclusive)
      {
         lock.writeLock().lock();
      }
      else
      {
         lock.readLock().lock();
      }
   }
View Full Code Here

    *
    * @param fqn the Fqn to release
    */
   public void releaseLock(Fqn fqn)
   {
      ReentrantReadWriteLock lock = getLock(fqn);
      if (lock.isWriteLockedByCurrentThread())
      {
         lock.writeLock().unlock();
      }
      else
      {
         lock.readLock().unlock();
      }
   }
View Full Code Here

   ReentrantReadWriteLock.WriteLock wl;

   @BeforeMethod(alwaysRun = true)
   public void setUp() throws Exception
   {
      lock = new ReentrantReadWriteLock();
      rl = lock.readLock();
      wl = lock.writeLock();
   }
View Full Code Here

          + globalMaxAppAttempts + "]. Use the global max attempts instead.");
    } else {
      this.maxAppAttempts = individualMaxAppAttempts;
    }

    ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
    this.readLock = lock.readLock();
    this.writeLock = lock.writeLock();

    this.stateMachine = stateMachineFactory.make(this);
  }
View Full Code Here

    this.eventHandler = rmContext.getDispatcher().getEventHandler();
    this.submissionContext = submissionContext;
    this.scheduler = scheduler;
    this.masterService = masterService;

    ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
    this.readLock = lock.readLock();
    this.writeLock = lock.writeLock();

    this.proxiedTrackingUrl = generateProxyUriWithoutScheme();
   
    this.stateMachine = stateMachineFactory.make(this);
    this.user = user;
View Full Code Here

  DefaultServiceDiscovered(String name) {
    this.name = name;
    this.discoverables = new AtomicReference<Set<Discoverable>>(ImmutableSet.<Discoverable>of());
    this.listenerCallers = Lists.newLinkedList();
    this.callerLock = new ReentrantReadWriteLock();
  }
View Full Code Here

{
    private final Lock readLock, writeLock;

    protected LockSupport()
    {
        ReentrantReadWriteLock lock = new ReentrantReadWriteLock();

        readLock = lock.readLock();
        writeLock = lock.writeLock();
    }
View Full Code Here

   * byte[] objects and reduce heap usage.
   */
  private final NameCache<ByteArray> nameCache;

  FSDirectory(FSImage fsImage, FSNamesystem ns, Configuration conf) {
    this.dirLock = new ReentrantReadWriteLock(true); // fair
    this.cond = dirLock.writeLock().newCondition();
    rootDir = new INodeDirectoryWithQuota(INodeDirectory.ROOT_NAME,
        ns.createFsOwnerPermissions(new FsPermission((short)0755)),
        Integer.MAX_VALUE, UNKNOWN_DISK_SPACE);
    this.fsImage = fsImage;
View Full Code Here

TOP

Related Classes of java.util.concurrent.locks.ReentrantReadWriteLock

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.