Examples of Latch


Examples of EDU.oswego.cs.dl.util.concurrent.Latch

                        && !readLockMap.hasDependency(changeLog)) {
                    activeWriter = new WriteLockImpl(changeLog);
                    activeWriterId = getCurrentThreadId();
                    return activeWriter;
                } else {
                    signal = new Latch();
                    waitingWriters.add(signal);
                }
            } finally {
                exclusive.release();
            }
View Full Code Here

Examples of EDU.oswego.cs.dl.util.concurrent.Latch

                if (activeWriter == null
                        || !hasDependency(activeWriter.changes, id)) {
                    readLockMap.addLock(id);
                    return new ReadLockImpl(id);
                } else {
                    signal = new Latch();
                    waitingReaders.add(signal);
                }
            } finally {
                shared.release();
            }
View Full Code Here

Examples of EDU.oswego.cs.dl.util.concurrent.Latch

                        && !readLockMap.hasDependency(changeLog)) {
                    activeWriter = new WriteLockImpl(changeLog);
                    activeWriterThread = Thread.currentThread();
                    return activeWriter;
                } else {
                    signal = new Latch();
                    waitingWriters.add(signal);
                }
            } finally {
                exclusive.release();
            }
View Full Code Here

Examples of EDU.oswego.cs.dl.util.concurrent.Latch

                        || !hasDependency(activeWriter.changes, id)) {
                    readerCount.incrementAndGet();
                    readLockMap.addLock(id);
                    return new ReadLockImpl(id);
                } else {
                    signal = new Latch();
                    waitingReaders.add(signal);
                }
            } finally {
                shared.release();
            }
View Full Code Here

Examples of EDU.oswego.cs.dl.util.concurrent.Latch

                        && !readLockMap.hasDependency(changeLog)) {
                    activeWriter = new WriteLockImpl(changeLog);
                    activeWriterId = getCurrentThreadId();
                    return activeWriter;
                } else {
                    signal = new Latch();
                    waitingWriters.add(signal);
                }
            } finally {
                exclusive.release();
            }
View Full Code Here

Examples of EDU.oswego.cs.dl.util.concurrent.Latch

 
        conn.start();
 
        final List received = new ArrayList();
        final List received2 = new ArrayList();
        final Latch latch = new Latch();
        final Latch latch2 = new Latch();
 
        new Thread(new Runnable()
        {
           public void run()
           {
              try
              {
                 while(true)
                 {
                    Message m = c.receive(1000);
                    if (m != null)
                    {
                       received.add(m);
                    }
                    else
                    {
                       latch.release();
                       return;
                    }
                 }
              }
              catch(Exception e)
              {
                 log.error("receive failed", e);
              }
           }
        }, "consumer thread 1").start();
 
        new Thread(new Runnable()
        {
           public void run()
           {
              try
              {
                 while(true)
                 {
                    Message m = c2.receive(1000);
                    if (m != null)
                    {
                       received2.add(m);
                    }
                    else
                    {
                       latch2.release();
                       return;
                    }
                 }
              }
              catch(Exception e)
              {
                 log.error("receive failed", e);
              }
           }
        }, "consumer thread 2").start();
 
        latch.acquire();
        latch2.acquire();
 
        assertEquals(5, received.size());
        for(Iterator i = received.iterator(); i.hasNext(); )
        {
           Message m = (Message)i.next();
View Full Code Here

Examples of EDU.oswego.cs.dl.util.concurrent.Latch

* */
public class SyncWorkExecutor implements WorkExecutor {

    public void doExecute(WorkerContext work, Executor executor)
            throws WorkException, InterruptedException {
        Latch latch = work.provideEndLatch();
        executor.execute(work);
        latch.acquire();
    }
View Full Code Here

Examples of EDU.oswego.cs.dl.util.concurrent.Latch

* */
public class StartWorkExecutor implements WorkExecutor {

    public void doExecute(WorkerContext work, Executor executor)
            throws WorkException, InterruptedException {
        Latch latch = work.provideStartLatch();
        executor.execute(work);
        latch.acquire();
    }
View Full Code Here

Examples of EDU.oswego.cs.dl.util.concurrent.Latch

        ActiveMQActivationSpec as = new ActiveMQActivationSpec();
        as.setDestination("TEST");
        as.setDestinationType(Queue.class.getName());
            ActivationSpecWrapper asWrapper = new ActivationSpecWrapper(as, raWrapper);

        final Latch messageDelivered = new Latch();
        MessageEndpointFactory messageEndpointFactory = new MessageEndpointFactory() {
            public MessageEndpoint createEndpoint(XAResource resource) throws UnavailableException {
                return new StubMessageEndpoint(etm, resource) {
                    public void onMessage(Message message) {
                        super.onMessage(message);
                        messageDelivered.release();
                    }

                    ;
                };
            }

            public boolean isDeliveryTransacted(Method method) throws NoSuchMethodException {
                return true;
            }
        };

        asWrapper.activate(messageEndpointFactory);

        Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
        MessageProducer producer = session.createProducer(new ActiveMQQueue("TEST"));
        producer.send(session.createTextMessage("Hello"));

        assertTrue(messageDelivered.attempt(1000 * 5));
    }
View Full Code Here

Examples of com.sleepycat.je.latch.Latch

            configMgr.getBoolean(EnvironmentParams.LOCK_OLD_LOCK_EXCEPTIONS);
        lockTables = new Map[nLockTables];
        lockTableLatches = new Latch[nLockTables];
        for (int i = 0; i < nLockTables; i++) {
            lockTables[i] = new HashMap<Long,Lock>();
            lockTableLatches[i] = new Latch("Lock Table " + i);
        }
        this.envImpl = envImpl;
        memoryBudget = envImpl.getMemoryBudget();

        stats = new StatGroup(GROUP_NAME, GROUP_DESC);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.