diff options
author | Caspar De Groot | 2011-07-26 10:20:00 +0000 |
---|---|---|
committer | Caspar De Groot | 2011-07-26 10:20:00 +0000 |
commit | a446533db04677db8686a47de128143ffd6c52f3 (patch) | |
tree | d4be33c0cdf37ed8c94755f5c21ae47acbd0956d /plugins/org.eclipse.net4j.util/src | |
parent | 22a22321c1ba1d08f3590bfb8723a6c8797848a1 (diff) | |
download | cdo-a446533db04677db8686a47de128143ffd6c52f3.tar.gz cdo-a446533db04677db8686a47de128143ffd6c52f3.tar.xz cdo-a446533db04677db8686a47de128143ffd6c52f3.zip |
[351793] Enhance LockMgr with write options
https://bugs.eclipse.org/bugs/show_bug.cgi?id=351793
Diffstat (limited to 'plugins/org.eclipse.net4j.util/src')
-rw-r--r-- | plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/concurrent/RWOLockManager.java | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/concurrent/RWOLockManager.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/concurrent/RWOLockManager.java index 48a8643252..d61dd27ee2 100644 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/concurrent/RWOLockManager.java +++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/concurrent/RWOLockManager.java @@ -26,6 +26,10 @@ import java.util.Map; import java.util.Set; /** + * Keeps track of locks on objects. Locks are owned by contexts. A particular combination of locks and their owners, for + * a given object, is represented by instances of the {@link LockState} class. This class is also repsonsible for + * deciding whether or not a new lock can be granted, based on the locks already present. + * * @author Caspar De Groot * @since 3.2 */ @@ -284,7 +288,17 @@ public class RWOLockManager<OBJECT, CONTEXT> extends Lifecycle implements IRWLoc } /** - * Represents a combination of locks for one OBJECT. + * Represents a combination of locks for one OBJECT. The different lock types are represented by the values of the + * enum {@link LockType}. + * <p> + * The locking semantics established by this class are as follows: + * <li>a read lock prevents a write lock by another, but allows read locks by others and allows a write option by + * another, and is therefore <b>non-exclusive</b></li> + * <li>a write lock prevents read locks by others, a write lock by another, and a write option by another, and is + * therefore <b>exclusive</b></li> + * <li>a write option prevents write locks by others and a write option by another, but allows read locks by others, + * and is therefore <b>exclusive</b></li> + * <p> * * @author Caspar De Groot * @since 3.2 @@ -561,6 +575,11 @@ public class RWOLockManager<OBJECT, CONTEXT> extends Lifecycle implements IRWLoc return false; } + if (writeLockOwner != null && writeLockOwner != context) + { + return false; + } + return true; } |