|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.yworks.yfiles.server.tiles.support.ReadWriteLock
A ReadWriteLock instance can be used to manage read and write access such that simultaneous read access is allowed, but only a single thread is allowed to write. This implementation allows reentrant calls, i.e., threads that have already acquired a read or write lock can call readLock() or writeLock() again. The yFiles AJAX Servlets make heavy use of the read/write lock mechanism in order to prevent concurrent modifications to graph instances while being able to serve multiple simultaneous read requests when the graph is not modified. To obtain read/write locks for a graph instance, the corresponding convenience methods provided by class BaseServlet can be used. Threads that acquire a read or write lock have to make sure that the locks are properly released after the read or write operations:
BaseServlet.readLock(graph); try { // read graph, e.g. iterate over the graph's nodes } finally { BaseServlet.unlockRead(graph) }
BaseServlet.readLock(y.view.Graph2D)
,
BaseServlet.unlockRead(y.view.Graph2D)
,
BaseServlet.writeLock(y.view.Graph2D)
,
BaseServlet.unlockWrite(y.view.Graph2D)
Constructor Summary | |
ReadWriteLock()
|
Method Summary | |
protected void |
onWriteFinished()
Called when unlockWrite() has been called for the last active writer. |
void |
readLock()
Acquire a read lock. |
void |
unlockRead()
Release a read lock that has been acquired using readLock() . |
void |
unlockWrite()
Release a write lock that has been acquired using writeLock() . |
void |
writeLock()
Acquire a write lock. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public ReadWriteLock()
Method Detail |
public void readLock()
unlockRead()
:
readWriteLock.readLock(); try { // read } finally { readWriteLock.unlockRead() }
public void unlockRead()
readLock()
.
readLock()
public void writeLock()
unlockWrite()
:
readWriteLock.writeLock(); try { // write } finally { readWriteLock.unlockWrite() }
public void unlockWrite()
writeLock()
.
writeLock()
protected void onWriteFinished()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |