Examples of Mutex


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

        return p;
    }

    public void setup() throws ProtocolException {
        log = LogFactory.getLog(SocketProtocol.class.getName() + ":" + getNextConnectionId());
        sendMutex = new Mutex();
        headerBuffer = ByteBuffer.allocate(4);
        serviceReadMutex = new Object();
        serviceWriteMutex = new Object();

        if (address == null && acceptedSocketChannel == null) throw new IllegalStateException("No address set");
View Full Code Here

Examples of Framework.Mutex

    public ServiceConcurrency getConcurrency() {
        return this.concurrency;
    }

    public void setInitLock(Mutex initLock) {
        Mutex oldValue = this.initLock;
        this.initLock = initLock;
        this.qq_Listeners.firePropertyChange("initLock", oldValue, this.initLock);
    }
View Full Code Here

Examples of Framework.Mutex

    public ServiceConcurrency getConcurrency() {
        return this.concurrency;
    }

    public void setInitLock(Mutex initLock) {
        Mutex oldValue = this.initLock;
        this.initLock = initLock;
        this.qq_Listeners.firePropertyChange("initLock", oldValue, this.initLock);
    }
View Full Code Here

Examples of net.sf.ehcache.concurrent.Mutex

     *                              acquire a lock in that time
     * @throws RuntimeException     if thrown the lock will not released. Catch and call<code>put(new Element(key, null));</code>
     *                              to release the lock acquired.
     */
    public Element get(final Object key) throws RuntimeException, LockTimeoutException {
        Mutex lock = getLockForKey(key);
        try {
            if (timeoutMillis == 0) {
                lock.acquire();
            } else {
                boolean acquired = lock.attempt(timeoutMillis);
                if (!acquired) {
                    StringBuffer message = new StringBuffer("Lock timeout. Waited more than ")
                            .append(timeoutMillis)
                            .append("ms to acquire lock for key ")
                            .append(key).append(" on blocking cache ").append(cache.getName());
                    throw new LockTimeoutException(message.toString());
                }
            }
            final Element element = cache.get(key);
            if (element != null) {
                //ok let the other threads in
                lock.release();
                return element;
            } else {
                //don't release the read lock until we put
                return null;
            }
View Full Code Here

Examples of net.sf.ehcache.concurrent.Mutex

            return;
        }
        Object key = element.getObjectKey();
        Object value = element.getObjectValue();

        Mutex lock = getLockForKey(key);
        try {
            if (value != null) {
                cache.put(element);
            } else {
                cache.remove(key);
            }
        } finally {
            //Release the readlock here. This will have been acquired in the get, where the element was null
            lock.release();
        }
    }
View Full Code Here

Examples of net.sf.ehcache.concurrent.Mutex

            Element element = backingCache.get(key);

            if (element == null) {
                element = super.get(key);
            } else {
                Mutex lock = stripedMutex.getMutexForKey(key);
                try {
                    lock.acquire();
                    update(key);
                } finally {
                    lock.release();
                }
            }
            return element;
        } catch (final Throwable throwable) {
            // Could not fetch - Ditch the entry from the cache and rethrow
View Full Code Here

Examples of net.sf.ehcache.constructs.concurrent.Mutex

            Element element = backingCache.get(key);

            if (element == null) {
                element = super.get(key);
            } else {
                Mutex lock = getLockForKey(key);
                try {
                    lock.acquire();
                    update(key);
                } finally {
                    lock.release();
                }
            }
            return element;
        } catch (final Throwable throwable) {
            // Could not fetch - Ditch the entry from the cache and rethrow
View Full Code Here

Examples of net.sf.ehcache.constructs.concurrent.Mutex

     *                              acquire a lock in that time
     * @throws RuntimeException     if thrown the lock will not released. Catch and call<code>put(new Element(key, null));</code>
     *                              to release the lock acquired.
     */
    public Element get(final Object key) throws RuntimeException, LockTimeoutException {
        Mutex lock = getLockForKey(key);
        try {
            if (timeoutMillis == 0) {
                lock.acquire();
            } else {
                boolean acquired = lock.attempt(timeoutMillis);
                if (!acquired) {
                    StringBuffer message = new StringBuffer("Lock timeout. Waited more than ")
                            .append(timeoutMillis)
                            .append("ms to acquire lock for key ")
                            .append(key).append(" on blocking cache ").append(cache.getName());
                    throw new LockTimeoutException(message.toString());
                }
            }
            final Element element = cache.get(key);
            if (element != null) {
                //ok let the other threads in
                lock.release();
                return element;
            } else {
                //don't release the read lock until we put
                return null;
            }
View Full Code Here

Examples of net.sf.ehcache.constructs.concurrent.Mutex

            return;
        }
        Object key = element.getObjectKey();
        Object value = element.getObjectValue();

        Mutex lock = getLockForKey(key);
        try {
            if (value != null) {
                cache.put(element);
            } else {
                cache.remove(key);
            }
        } finally {
            //Release the readlock here. This will have been acquired in the get, where the element was null
            lock.release();
        }
    }
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.