.. 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 ReadAccessSemaphore =================== .. java:package:: org.caosdb.server.database :noindex: .. java:type:: class ReadAccessSemaphore extends Semaphore implements Releasable Acquire and release read access. \ :java:ref:`DatabaseAccessManager`\ uses this class for managing access to the back-end during processing updates, inserts, deletions and retrievals. Read access will be granted immediately for every thread that requests it, unless a thread requests that read access be blocked (usually by requesting write access). If this happens, all threads that already have read access will proceed and release their read access as usual but no NEW read permits will be granted. This is a blockable \ :java:ref:`Semaphore`\ . Any number of threads may acquire a permit unless it is blocked. The blocking thread (requesting a \ :java:ref:`WriteAccessLock`\ ) waits until all threads have released their permits. :author: Timm Fitschen Fields ------ writersBlock ^^^^^^^^^^^^ .. java:field:: Semaphore writersBlock :outertype: ReadAccessSemaphore Constructors ------------ ReadAccessSemaphore ^^^^^^^^^^^^^^^^^^^ .. java:constructor:: public ReadAccessSemaphore() :outertype: ReadAccessSemaphore Methods ------- acquire ^^^^^^^ .. java:method:: @Override public void acquire() throws InterruptedException :outertype: ReadAccessSemaphore Acquire a read access permit if and only if it has not been blocked via block(). If read access is currently blocked, the thread waits until the unblock() method is invoked by any thread. block ^^^^^ .. java:method:: public void block() throws InterruptedException :outertype: ReadAccessSemaphore Acquire the permit to block further read access, if no thread currently has acquired read access and no thread currently has a block. Consequences of calling this method are: .. * Further read access permits are blocked for any thread. * Every thread that has a read access already can proceed. The current thread waits until all threads have released their read access. If another thread has invoked this method before, the current thread waits until the unblock() method is called. :throws InterruptedException: release ^^^^^^^ .. java:method:: @Override public void release() :outertype: ReadAccessSemaphore Release a read access permit. If this is the last remaining acquired permit, also release the general writersBlock. unblock ^^^^^^^ .. java:method:: public void unblock() :outertype: ReadAccessSemaphore Unblock read access. This method releases the writersBlock introduced by calling the block() method. waitingAquireAccess ^^^^^^^^^^^^^^^^^^^ .. java:method:: public int waitingAquireAccess() :outertype: ReadAccessSemaphore