.. java:import:: java.util.concurrent Semaphore .. java:import:: java.util.concurrent.atomic AtomicInteger .. java:import:: java.util.concurrent.locks ReentrantLock .. java:import:: org.caosdb.server.database.access Access .. java:import:: org.caosdb.server.database.access AccessControlAccess .. java:import:: org.caosdb.server.database.access InfoAccess .. java:import:: org.caosdb.server.database.access InitAccess .. java:import:: org.caosdb.server.database.access TransactionAccess .. java:import:: org.caosdb.server.transaction AccessControlTransaction .. java:import:: org.caosdb.server.transaction TransactionInterface .. java:import:: org.caosdb.server.transaction WriteTransactionInterface .. java:import:: org.caosdb.server.utils Info .. java:import:: org.caosdb.server.utils Initialization .. java:import:: org.caosdb.server.utils Releasable WriteAccessLock =============== .. java:package:: org.caosdb.server.database :noindex: .. java:type:: class WriteAccessLock extends ReentrantLock implements Releasable Acquire and release write access. DatabaseAccessManager uses this class for managing access to entities while processing updates, inserts, deletions and retrievals. Write access will be granted to one and only one thread if no other thread already holds read or write access permits. The write access seat has to be reserved before acquiring the lock. The flow is as follows: .. parsed-literal:: No new read access possible, Read access Read access wait for running read possible possible threads to fininish +------+ +----------+ +----------+ +--> | no | ----> | reserved | ----> | acquired | --+ | | Lock | +----------+ +----------+ | | +------+ \ / | | (1 seat together) | +-----------------------------------------------------+ release() :author: Timm Fitschen Constructors ------------ WriteAccessLock ^^^^^^^^^^^^^^^ .. java:constructor:: public WriteAccessLock(ReadAccessSemaphore readSem) :outertype: WriteAccessLock Methods ------- lockInterruptibly ^^^^^^^^^^^^^^^^^ .. java:method:: @Override public void lockInterruptibly() throws InterruptedException :outertype: WriteAccessLock Lock the write access seat. This method returns once all current read permits have been released. release ^^^^^^^ .. java:method:: @Override public void release() :outertype: WriteAccessLock reserve ^^^^^^^ .. java:method:: public void reserve() throws InterruptedException :outertype: WriteAccessLock Reserve the seat for the next write access. While a write access is reserved but not yet acquired, all read access may still be granted. When a write access has been already granted or another reservation is active, the thread waits until the write access has been released. :throws InterruptedException: unlock ^^^^^^ .. java:method:: @Override public void unlock() :outertype: WriteAccessLock whoHasReservedAccess ^^^^^^^^^^^^^^^^^^^^ .. java:method:: public Thread whoHasReservedAccess() :outertype: WriteAccessLock