All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.sqlite.UnlockNotification Maven / Gradle / Ivy

The newest version!
package org.sqlite;

import java.util.concurrent.locks.Condition;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;

class UnlockNotification {
	private boolean fired; // True after unlock event has occurred
	private final Lock mutex = new ReentrantLock(); // Mutex to protect structure
	private final Condition cond = mutex.newCondition();

	void fire() {
		mutex.lock();
		try {
			fired = true;
			cond.signal();
		} finally {
			mutex.unlock();
		}
	}

	void await(Conn c) throws ConnException {
		mutex.lock();
		try {
			if (!fired) {
				cond.await();
			}
		} catch (InterruptedException e) {
			throw new ConnException(c, e.getMessage(), ErrCodes.WRAPPER_SPECIFIC); // TODO Validate
		} finally {
			mutex.unlock();
		}
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy