public class DockHierarchyLock extends Object
DockHierarchyLock allows DockStations to defend
themselves against concurrent modifications of the hierarchy. At any time only
one DockStation or a class working with DockStations in the realm
of a DockController can acquire the lock.| Modifier and Type | Class and Description |
|---|---|
static class |
DockHierarchyLock.Token
Is acquired from a
DockHierarchyLock and releases the lock. |
| Constructor and Description |
|---|
DockHierarchyLock() |
| Modifier and Type | Method and Description |
|---|---|
DockHierarchyLock.Token |
acquire(DockStation station)
Acquires a lock describing the entire contents of
station. |
static DockHierarchyLock.Token |
acquireFake()
Acquires a fake token which does not lock anything.
|
DockHierarchyLock.Token |
acquireLink(DockStation station,
Dockable dockable)
Allows
station to become the new parent of dockable. |
static DockHierarchyLock.Token |
acquireLinking(DockStation station,
Dockable dockable)
The same as calling
acquireLink(DockStation, Dockable) with the DockHierarchyLock of
the DockController of station. |
DockHierarchyLock.Token |
acquireUnlink(DockStation station,
Dockable dockable)
Allows
station to remove itself as parent from dockable. |
static DockHierarchyLock.Token |
acquireUnlinking(DockStation station,
Dockable dockable)
The same as calling
acquireUnlink(DockStation, Dockable) with the DockHierarchyLock of
the DockController of station. |
static DockHierarchyLock.Token |
acquiring(DockStation station)
The same as calling
acquire(DockStation) with the DockHierarchyLock of
the DockController of station. |
boolean |
isConcurrent()
Whether this lock throws exceptions or is silent.
|
boolean |
isHardExceptions()
Tells whether hard exceptions should be thrown or only printed.
|
void |
onRelease(Runnable run)
Executes
run once no DockHierarchyLock.Token is acquired anymore. |
void |
setConcurrent(boolean concurrent)
Tells this lock whether concurrent modifications are allowed or not.
|
void |
setHardExceptions(boolean hardExceptions)
Sets whether exceptions should be thrown or only printed.
|
public void setHardExceptions(boolean hardExceptions)
hardExceptions - true if the exceptions should be thrownpublic boolean isHardExceptions()
true if exceptions should be thrownsetHardExceptions(boolean)public void setConcurrent(boolean concurrent)
concurrent - whether to allow concurrent modification or notpublic boolean isConcurrent()
true, then this lock is silentisConcurrent()public void onRelease(Runnable run)
run once no DockHierarchyLock.Token is acquired anymore. The exact order of how and when
the Runnables are executed is:
isConcurrent() returns true will be ignored.Runnables, run will be added to the end of that queue. The queue
will be executed from the beginning to the end, this order cannot be changed.run will never be executed directly.DockHierarchyLock.Token is acquired, then run is executed immediately.run is always executed in the EDT, other Threads may be blocked until run
is completedrun - the Runnable to executed, not nullIllegalArgumentException - if run is nullIllegalStateException - if an InterruptedException is caughtpublic static DockHierarchyLock.Token acquireLinking(DockStation station, Dockable dockable)
acquireLink(DockStation, Dockable) with the DockHierarchyLock of
the DockController of station. Returns a fake DockHierarchyLock.Token if station has
no DockController.station - the station which wants to be the new parent of dockabledockable - a dockable with no parentIllegalStateException - if dockable has a parent or station
thinks that dockable is one of its childrenpublic static DockHierarchyLock.Token acquireUnlinking(DockStation station, Dockable dockable)
acquireUnlink(DockStation, Dockable) with the DockHierarchyLock of
the DockController of station. Returns a fake DockHierarchyLock.Token if station has
no DockController.station - the current parent of dockabledockable - a dockable with station as parentIllegalStateException - if dockable is not a child of
stationpublic static DockHierarchyLock.Token acquiring(DockStation station)
acquire(DockStation) with the DockHierarchyLock of
the DockController of station. Returns a fake DockHierarchyLock.Token if station has
no DockController.station - the station to lockIllegalStateException - if a lock has already been acquiredpublic static DockHierarchyLock.Token acquireFake()
public DockHierarchyLock.Token acquireLink(DockStation station, Dockable dockable)
station to become the new parent of dockable.station - the station which wants to be the new parent of dockabledockable - a dockable with no parentIllegalStateException - if dockable has a parent or station
thinks that dockable is one of its childrenpublic DockHierarchyLock.Token acquireUnlink(DockStation station, Dockable dockable)
station to remove itself as parent from dockable.station - the current parent of dockabledockable - a dockable with station as parentIllegalStateException - if dockable is not a child of
stationpublic DockHierarchyLock.Token acquire(DockStation station)
station. This
method is intended in situations where the layout of station gets
modified and this modification must not be interrupted.station - the station for which a lock is requestedIllegalStateException - if the lock is already acquiredCopyright © 2017 Docking Frames. All rights reserved.