Package EDU.oswego.cs.dl.util.concurrent

Examples of EDU.oswego.cs.dl.util.concurrent.FIFOSemaphore$FIFOWaitQueue


    */
   public void initialize(Container container, int maxSize, long timeout)
   {
      super.initialize(container, maxSize, timeout);
      this.maxSize = maxSize;
      this.strictMaxSize = new FIFOSemaphore(maxSize);
      this.strictTimeout = timeout;
   }
View Full Code Here


   }
  
   public void setMaxSize(int maxSize)
   {
      this.maxSize = maxSize;
      this.strictMaxSize = new FIFOSemaphore(maxSize);
   }
View Full Code Here

        this.next = next;
        this.defaultSubject = defaultSubject;
        this.defaultCRI = defaultCRI;
        this.maxSize = maxSize;
        this.blockingTimeout = blockingTimeout;
        permits = new FIFOSemaphore(maxSize);
        pool = new PoolDeque(maxSize);
    }
View Full Code Here

            int maxSize,
            int blockingTimeout) {
        this.next = next;
        this.maxSize = maxSize;
        this.blockingTimeout = blockingTimeout;
        permits = new FIFOSemaphore(maxSize);
        pool = new HashMap(maxSize);
    }
View Full Code Here

            int maxSize,
            int blockingTimeout,
            boolean selectOneAssumeMatch) {
        this.next = next;
        this.blockingTimeout = blockingTimeout;
        permits = new FIFOSemaphore(maxSize);
        pool = new PoolDeque(maxSize);
        this.selectOneAssumeMatch = selectOneAssumeMatch;
    }
View Full Code Here

   private FIFOSemaphore sem_;

   public LockStrategySerializable()
   {
      permits_ = 1;
      sem_ = new FIFOSemaphore(permits_);
   }
View Full Code Here

    * T1 reads data - 20
    * </ol>
    */
   public void testReadUncommitted() throws Throwable {
      final LockStrategy s=new LockStrategyReadUncommitted();
      final FIFOSemaphore sem=new MyFIFOSemaphore(1);
      final CyclicBarrier barrier=new CyclicBarrier(2);

      Thread t1=new Thread("t1") {
         Sync lock=null;

         public void run() {
            try {
               sem.acquire(); // we're first to the semaphore

               // log("waiting on barrier");
               barrier.barrier(); // wait until t2 joins us
               // log("passed barrier");
               lock=s.readLock();
               lock.attempt(TIMEOUT);
               log("1st read: value is " + value);
               assertEquals(10, value);
               sem.release(); // give t2 time to make the modification
               TestingUtil.sleepThread(100);

               sem.acquire(); // to read the uncommitted modification by t2
               log("2nd read: value is " + value + "; we should see t2's uncommitted change (20)");
               assertEquals(20, value); // we're seeing the modification by t2 before t2 committed (a.k.a. released the lock)
               sem.release();
               TestingUtil.sleepThread(100);

               sem.acquire(); // to read the committed change by t2
               log("3rd read: value is still " + value + "; we should see t2's committed change");
               assertEquals(20, value);
            }
            catch(Throwable ex) {
               t1_ex=ex;
            }
            finally {
               if(lock != null)
                  lock.release();
               sem.release();
            }
         }
      };


      Thread t2=new Thread("t2") {
         Sync lock=null;

         public void run() {
            try {
               TestingUtil.sleepThread(100);
               barrier.barrier();
               sem.acquire();
               lock=s.writeLock();
               lock.attempt(TIMEOUT);
               log("changing value from " + value + " to 20");
               value=20;
               sem.release(); // now t1 can read the uncommitted modification
               TestingUtil.sleepThread(100);

               sem.acquire(); // to release the lock
               log("committing the TX");
               lock.release();
            }
            catch(Throwable ex) {
               t2_ex=ex;
            }
            finally {
               if(lock != null)
                  lock.release();
               sem.release();
            }
         }
      };

      t1.start();
View Full Code Here

   {
   }

   public QueuedClientSocketFactory(long nPermits)
   {
      permits = new FIFOSemaphore(nPermits);
      numPermits = nPermits;
   }
View Full Code Here

   }
   public void readExternal(java.io.ObjectInput in)
      throws IOException, ClassNotFoundException
   {
      numPermits = in.readLong();
      permits = new FIFOSemaphore(numPermits);
   }
View Full Code Here

   private FIFOSemaphore sem_;

   public SimpleLock()
   {
      permits_ = 1;
      sem_ = new FIFOSemaphore(permits_);
   }
View Full Code Here

TOP

Related Classes of EDU.oswego.cs.dl.util.concurrent.FIFOSemaphore$FIFOWaitQueue

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.