Package org.exist.util

Examples of org.exist.util.LockException


        do {
            synchronized (monitor) {
                try {
                    monitor.wait(500);
                } catch (final InterruptedException e) {
                    throw new LockException("Interrupted while waiting for read lock");
                }
            }
            if (deadlocked) {
                LOG.warn("Deadlock detected: cancelling wait...");
                throw new DeadlockException();
View Full Code Here


            waiter = new WaitingThread(thisThread, thisThread, this, Lock.WRITE_LOCK);
            addWaitingWrite(waiter);
            DeadlockDetection.addResourceWaiter(thisThread, waiter);
        }
        List<WaitingThread> deadlockedThreads = null;
        LockException exceptionCaught = null;
        synchronized (thisThread) {
            if (thisThread != writeLockedThread) {
                while (thisThread != writeLockedThread && deadlockedThreads == null) {
                    if (LockOwner.DEBUG) {
                        final StringBuffer buf = new StringBuffer("Waiting for write: ");
View Full Code Here

        if (mode == Lock.NO_LOCK) {
            LOG.warn("acquired with no lock !");
            return true;
        }
        if (Thread.interrupted())
            {throw new LockException();}
        Thread caller = Thread.currentThread();
        synchronized (this) {
            WaitingThread waitingOnResource;
            if (caller == owner_) {
                ++holds_;
                modeStack.push(Integer.valueOf(mode));
                if (mode == Lock.WRITE_LOCK)
                    {writeLocks++;}
                if (DEBUG) {
                    final Throwable t = new Throwable();
                    seStack.push(t.getStackTrace());
                }
                mode_ = mode;
                return true;
            } else if (owner_ == null) {
                owner_ = caller;
                holds_ = 1;
                modeStack.push(Integer.valueOf(mode));
                if (mode== Lock.WRITE_LOCK)
                    {writeLocks++;}
                if (DEBUG) {
                    final Throwable t = new Throwable();
                    seStack.push(t.getStackTrace());
                }
                mode_ = mode;
                return true;
            } else if ((waitingOnResource =
                    DeadlockDetection.deadlockCheckResource(caller, owner_)) != null) {
                waitingOnResource.suspendWaiting();
                final SuspendedWaiter suspended = new SuspendedWaiter(owner_, mode_, holds_);
                suspendedThreads.push(suspended);
                owner_ = caller;
                holds_ = 1;
                modeStack.push(Integer.valueOf(mode));
                if (mode== Lock.WRITE_LOCK)
                    {writeLocks++;}
                mode_ = mode;
                listener = waitingOnResource;
                return true;
            } else {
                DeadlockDetection.addCollectionWaiter(caller, this);
                try {
                    for (;;) {
                        wait(WAIT_CHECK_PERIOD);
                        if ((waitingOnResource = DeadlockDetection.deadlockCheckResource(caller, owner_)) != null) {
                            waitingOnResource.suspendWaiting();
                            final SuspendedWaiter suspended = new SuspendedWaiter(owner_, mode_, holds_);
                            suspendedThreads.push(suspended);
                            owner_ = caller;
                            holds_ = 1;
                            modeStack.push(Integer.valueOf(mode));
                            if (mode== Lock.WRITE_LOCK)
                                {writeLocks++;}
                            mode_ = mode;
                            listener = waitingOnResource;
                            DeadlockDetection.clearCollectionWaiter(owner_);
                            return true;
                        } else if (caller == owner_) {
                            ++holds_;
                            modeStack.push(Integer.valueOf(mode));
                            if (mode == Lock.WRITE_LOCK)
                                {writeLocks++;}
                            if (DEBUG) {
                                final Throwable t = new Throwable();
                                seStack.push(t.getStackTrace());
                            }
                            mode_ = mode;
                            DeadlockDetection.clearCollectionWaiter(owner_);
                            return true;
                        } else if (owner_ == null) {
                            owner_ = caller;
                            holds_ = 1;
                            modeStack.push(Integer.valueOf(mode));
                            if (mode == Lock.WRITE_LOCK)
                                {writeLocks++;}
                            if (DEBUG) {
                                final Throwable t = new Throwable();
                                seStack.push(t.getStackTrace());
                            }
                            mode_ = mode;
                            DeadlockDetection.clearCollectionWaiter(owner_);
                            return true;
                        }
                    }
                } catch (final InterruptedException ex) {
                    notify();
                    throw new LockException("Interrupted while waiting for lock");
                }
            }
        }
    }
View Full Code Here

TOP

Related Classes of org.exist.util.LockException

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.