The locks are NOT reentrant. In particular, even though it may appear to usually work OK, a thread holding a read lock should not attempt to re-acquire it. Doing so risks lockouts when there are also waiting writers.
Introduction to this package.
| Modifier and Type | Class and Description |
|---|---|
| protected class | |
| protected abstract class | WriterPreferenceReadWriteLock.Signaller
Reader and Writer requests are maintained in two different wait sets, by two different objects. |
| protected class |
| Modifier and Type | Field and Description |
|---|---|
| protected long | |
| protected Thread | |
| protected final WriterPreferenceReadWriteLock. | |
| protected long | |
| protected long | |
| protected final WriterPreferenceReadWriteLock. |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| protected boolean | |
| protected synchronized void | |
| protected synchronized void | |
| protected synchronized WriterPreferenceReadWriteLock. | |
| protected synchronized WriterPreferenceReadWriteLock. | |
| public Sync | |
| protected synchronized boolean | |
| protected synchronized boolean | |
| protected synchronized boolean | |
| protected synchronized boolean | |
| protected synchronized boolean | |
| protected synchronized boolean | |
| public Sync |
| activeReaders_ | back to summary |
|---|---|
| protected long activeReaders_ | |
| activeWriter_ | back to summary |
|---|---|
| protected Thread activeWriter_ | |
| readerLock_ | back to summary |
|---|---|
| protected final WriterPreferenceReadWriteLock. | |
| waitingReaders_ | back to summary |
|---|---|
| protected long waitingReaders_ | |
| waitingWriters_ | back to summary |
|---|---|
| protected long waitingWriters_ | |
| writerLock_ | back to summary |
|---|---|
| protected final WriterPreferenceReadWriteLock. | |
| WriterPreferenceReadWriteLock | back to summary |
|---|---|
| public WriterPreferenceReadWriteLock() | |
| allowReader | back to summary |
|---|---|
| protected boolean allowReader() Override this method to change to reader preference | |
| cancelledWaitingReader | back to summary |
|---|---|
| protected synchronized void cancelledWaitingReader() | |
| cancelledWaitingWriter | back to summary |
|---|---|
| protected synchronized void cancelledWaitingWriter() | |
| endRead | back to summary |
|---|---|
| protected synchronized WriterPreferenceReadWriteLock. Called upon termination of a read. Returns the object to signal to wake up a waiter, or null if no such | |
| endWrite | back to summary |
|---|---|
| protected synchronized WriterPreferenceReadWriteLock. Called upon termination of a write. Returns the object to signal to wake up a waiter, or null if no such | |
| readLock | back to summary |
|---|---|
| public Sync readLock() Implements EDU. Doc from EDU. get the readLock | |
| startRead | back to summary |
|---|---|
| protected synchronized boolean startRead() | |
| startReadFromNewReader | back to summary |
|---|---|
| protected synchronized boolean startReadFromNewReader() | |
| startReadFromWaitingReader | back to summary |
|---|---|
| protected synchronized boolean startReadFromWaitingReader() | |
| startWrite | back to summary |
|---|---|
| protected synchronized boolean startWrite() | |
| startWriteFromNewWriter | back to summary |
|---|---|
| protected synchronized boolean startWriteFromNewWriter() | |
| startWriteFromWaitingWriter | back to summary |
|---|---|
| protected synchronized boolean startWriteFromWaitingWriter() | |
| writeLock | back to summary |
|---|---|
| public Sync writeLock() Implements EDU. Doc from EDU. get the writeLock | |
| Access | Constructor and Description |
|---|---|
| protected |
| Modifier and Type | Method and Description |
|---|---|
| public void | acquire()
Implements EDU. |
| public boolean | attempt(long
the number of milleseconds to wait.
An argument less than or equal to zero means not to wait at all.
However, this may still require
access to a synchronization lock, which can impose unbounded
delay if there is a lot of contention among threads. msecs)Implements EDU. |
| public void | release()
Implements EDU. |
| pack-priv synchronized void |
| ReaderLock | back to summary |
|---|---|
| protected ReaderLock() | |
| acquire | back to summary |
|---|---|
| public void acquire() throws InterruptedException Implements EDU. Doc from EDU. Wait (possibly forever) until successful passage. Fail only upon interuption. Interruptions always result in `clean' failures. On failure, you can be sure that it has not been acquired, and that no corresponding release should be performed. Conversely, a normal return guarantees that the acquire was successful. | |
| attempt | back to summary |
|---|---|
| public boolean attempt(long msecs) throws InterruptedException Implements EDU. Doc from EDU. Wait at most msecs to pass; report whether passed. The method has best-effort semantics: The msecs bound cannot be guaranteed to be a precise upper bound on wait time in Java. Implementations generally can only attempt to return as soon as possible after the specified bound. Also, timers in Java do not stop during garbage collection, so timeouts can occur just because a GC intervened. So, msecs arguments should be used in a coarse-grained manner. Further, implementations cannot always guarantee that this method will return at all without blocking indefinitely when used in unintended ways. For example, deadlocks may be encountered when called in an unintended context.
| |
| release | back to summary |
|---|---|
| public void release() Implements EDU. Doc from EDU. Potentially enable others to pass. Because release does not raise exceptions, it can be used in `finally' clauses without requiring extra embedded try/catch blocks. But keep in mind that as with any java method, implementations may still throw unchecked exceptions such as Error or NullPointerException when faced with uncontinuable errors. However, these should normally only be caught by higher-level error handlers. | |
| signalWaiters | back to summary |
|---|---|
| pack-priv synchronized void signalWaiters() Implements abstract EDU. | |
| Access | Constructor and Description |
|---|---|
| protected |
| Modifier and Type | Method and Description |
|---|---|
| pack-priv abstract void |
| Signaller | back to summary |
|---|---|
| protected Signaller() | |
| signalWaiters | back to summary |
|---|---|
| pack-priv abstract void signalWaiters() | |
| Access | Constructor and Description |
|---|---|
| protected |
| Modifier and Type | Method and Description |
|---|---|
| public void | acquire()
Implements EDU. |
| public boolean | attempt(long
the number of milleseconds to wait.
An argument less than or equal to zero means not to wait at all.
However, this may still require
access to a synchronization lock, which can impose unbounded
delay if there is a lot of contention among threads. msecs)Implements EDU. |
| public void | release()
Implements EDU. |
| pack-priv synchronized void |
| WriterLock | back to summary |
|---|---|
| protected WriterLock() | |
| acquire | back to summary |
|---|---|
| public void acquire() throws InterruptedException Implements EDU. Doc from EDU. Wait (possibly forever) until successful passage. Fail only upon interuption. Interruptions always result in `clean' failures. On failure, you can be sure that it has not been acquired, and that no corresponding release should be performed. Conversely, a normal return guarantees that the acquire was successful. | |
| attempt | back to summary |
|---|---|
| public boolean attempt(long msecs) throws InterruptedException Implements EDU. Doc from EDU. Wait at most msecs to pass; report whether passed. The method has best-effort semantics: The msecs bound cannot be guaranteed to be a precise upper bound on wait time in Java. Implementations generally can only attempt to return as soon as possible after the specified bound. Also, timers in Java do not stop during garbage collection, so timeouts can occur just because a GC intervened. So, msecs arguments should be used in a coarse-grained manner. Further, implementations cannot always guarantee that this method will return at all without blocking indefinitely when used in unintended ways. For example, deadlocks may be encountered when called in an unintended context.
| |
| release | back to summary |
|---|---|
| public void release() Implements EDU. Doc from EDU. Potentially enable others to pass. Because release does not raise exceptions, it can be used in `finally' clauses without requiring extra embedded try/catch blocks. But keep in mind that as with any java method, implementations may still throw unchecked exceptions such as Error or NullPointerException when faced with uncontinuable errors. However, these should normally only be caught by higher-level error handlers. | |
| signalWaiters | back to summary |
|---|---|
| pack-priv synchronized void signalWaiters() Implements abstract EDU. | |