Package org.eclipse.net4j.util.concurrent

# Klasse RWOLockManager<OBJECT,CONTEXT>

java.lang.Object
org.eclipse.net4j.util.event.Notifier
org.eclipse.net4j.util.lifecycle.Lifecycle
org.eclipse.net4j.util.concurrent.RWOLockManager<OBJECT,CONTEXT>

Alle implementierten Schnittstellen:
  `IRWLockManager<OBJECT,CONTEXT>`, `IRWOLockManager<OBJECT,CONTEXT>`, `INotifier`, `INotifier.INotifier2`, `IDeactivateable`, `ILifecycle`, `ILifecycle.DeferrableActivation`

public class RWOLockManager<OBJECT,CONTEXT> extends Lifecycle implements IRWOLockManager<OBJECT,CONTEXT>
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 `RWOLockManager.LockState` class. This class is also responsible for deciding whether or not a new lock can be granted, based on the locks already present.

Seit:
  3.2
Autor:
  Caspar De Groot, Eike Stepper

## Verschachtelte Klassen - Übersicht

Verschachtelte Klassen
Modifizierer und Typ
Klasse
Beschreibung
`static class`
`RWOLockManager.LockState<OBJECT,CONTEXT>`
Represents a combination of locks for one OBJECT.

## Von Schnittstelle geerbte verschachtelte Klassen/Schnittstellen org.eclipse.net4j.util.lifecycle.ILifecycle

`ILifecycle.DeferrableActivation`

## Von Schnittstelle geerbte verschachtelte Klassen/Schnittstellen org.eclipse.net4j.util.event.INotifier

`INotifier.INotifier2`

## Von Schnittstelle geerbte verschachtelte Klassen/Schnittstellen org.eclipse.net4j.util.concurrent.IRWLockManager

`IRWLockManager.LockType`

## Von Schnittstelle geerbte verschachtelte Klassen/Schnittstellen org.eclipse.net4j.util.concurrent.IRWOLockManager

`IRWOLockManager.LockDeltaHandler<OBJECT,CONTEXT>`

## Feldübersicht

Felder
Modifizierer und Typ
Feld
Beschreibung
`protected final Access`
`read`
`protected final ReentrantReadWriteAccess`
`rwAccess`
`protected final Access`
`write`

### Von Klasse geerbte Felder org.eclipse.net4j.util.lifecycle.Lifecycle

`USE_LABEL`

### Von Schnittstelle geerbte Felder org.eclipse.net4j.util.concurrent.IRWLockManager

`NO_WAIT, WAIT`

### Von Schnittstelle geerbte Felder org.eclipse.net4j.util.concurrent.IRWOLockManager

`ALL_LOCK_TYPES, ALL_LOCKS, ALL_OBJECTS, NO_TIMEOUT`

## Konstruktorübersicht

Konstruktoren
Konstruktor
Beschreibung
`RWOLockManager()`

## Methodenübersicht

Modifizierer und Typ
Methode
Beschreibung
`protected void`
`changeContext(CONTEXT oldContext, CONTEXT newContext)`
`protected Map<CONTEXT,Set<RWOLockManager.LockState<OBJECT,CONTEXT>>>`
`createContextToLocksMap()`
`protected Map<OBJECT,RWOLockManager.LockState<OBJECT,CONTEXT>>`
`createObjectToLocksMap()`
`protected long`
`currentTimeMillis()`
`protected final Map<CONTEXT,Set<RWOLockManager.LockState<OBJECT,CONTEXT>>>`
`getContextToLocksMap()`
All access to the returned map must be properly synchronized on this `RWOLockManager`.
`RWOLockManager.LockState<OBJECT,CONTEXT>`
`getLockState(OBJECT key)`
`List<RWOLockManager.LockState<OBJECT,CONTEXT>>`
`getLockStates()`
Veraltet.
`void`
`getLockStates(Collection<OBJECT> keys, BiConsumer<OBJECT,RWOLockManager.LockState<OBJECT,CONTEXT>> consumer)`
`void`
`getLockStates(Consumer<RWOLockManager.LockState<OBJECT,CONTEXT>> consumer)`
`long`
`getModCount()`
`protected final Map<OBJECT,RWOLockManager.LockState<OBJECT,CONTEXT>>`
`getObjectToLocksMap()`
All access to the returned map must be properly synchronized on this `RWOLockManager`.
`boolean`
`hasLock(IRWLockManager.LockType type, CONTEXT context, OBJECT objectToLock)`
`boolean`
`hasLockByOthers(IRWLockManager.LockType type, CONTEXT context, OBJECT objectToLock)`
`long`
`lock(CONTEXT context, Collection<? extends OBJECT> objects, IRWLockManager.LockType lockType, int count, long timeout, IRWOLockManager.LockDeltaHandler<OBJECT,CONTEXT> deltaHandler, Consumer<RWOLockManager.LockState<OBJECT,CONTEXT>> stateHandler)`
Adds locks of the given lockType, owned by the given context to the given objects.
`void`
`lock(IRWLockManager.LockType type, CONTEXT context, Collection<? extends OBJECT> objectsToLock, long timeout)`
Veraltet.
`void`
`lock(IRWLockManager.LockType type, CONTEXT context, OBJECT objectToLock, long timeout)`
Veraltet.
`List<RWOLockManager.LockState<OBJECT,CONTEXT>>`
`lock2(IRWLockManager.LockType type, CONTEXT context, Collection<? extends OBJECT> objectsToLock, long timeout)`
Veraltet.
`void`
`setLockState(OBJECT key, RWOLockManager.LockState<OBJECT,CONTEXT> lockState)`
Veraltet.
`static void`
`setUnlockAll(boolean on)`
Veraltet.
`void`
`unlock(CONTEXT context)`
Veraltet.
`long`
`unlock(CONTEXT context, Collection<? extends OBJECT> objects, IRWLockManager.LockType lockType, int count, IRWOLockManager.LockDeltaHandler<OBJECT,CONTEXT> deltaHandler, Consumer<RWOLockManager.LockState<OBJECT,CONTEXT>> stateHandler)`
Removes locks of the given lockType, owned by the given context from the given objects.
`void`
`unlock(IRWLockManager.LockType type, CONTEXT context, Collection<? extends OBJECT> objectsToUnlock)`
Veraltet.
`List<RWOLockManager.LockState<OBJECT,CONTEXT>>`
`unlock2(CONTEXT context)`
Veraltet.
`List<RWOLockManager.LockState<OBJECT,CONTEXT>>`
`unlock2(CONTEXT context, Collection<? extends OBJECT> objectsToUnlock)`
Veraltet.
`List<RWOLockManager.LockState<OBJECT,CONTEXT>>`
`unlock2(IRWLockManager.LockType lockType, CONTEXT context, Collection<? extends OBJECT> objectsToUnlock)`
Veraltet.

### Von Klasse geerbte Methoden org.eclipse.net4j.util.lifecycle.Lifecycle

`activate, checkActive, checkArg, checkArg, checkInactive, checkNull, checkState, checkState, deactivate, deferredActivate, doActivate, doAfterActivate, doBeforeActivate, doBeforeDeactivate, doDeactivate, dump, getLifecycleState, isActive, isDeferredActivation, toString`

### Von Klasse geerbte Methoden org.eclipse.net4j.util.event.Notifier

`addListener, addUniqueListener, fireEvent, fireEvent, fireEvent, fireThrowable, firstListenerAdded, getListeners, getNotificationService, hasListener, hasListeners, lastListenerRemoved, listenerAdded, listenerRemoved, removeListener`

### Von Klasse geerbte Methoden java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

### Von Schnittstelle geerbte Methoden org.eclipse.net4j.util.event.INotifier

`addListener, getListeners, hasListeners, removeListener`

## Felddetails

### rwAccess

protected final ReentrantReadWriteAccess rwAccess

Seit:
  3.16

### read

protected final Access read

Seit:
  3.16

### write

protected final Access write

Seit:
  3.16

## Konstruktordetails

### RWOLockManager

public RWOLockManager()

## Methodendetails

### getModCount

public long getModCount()

Angegeben von:
  `getModCount` in Schnittstelle `IRWOLockManager<OBJECT,CONTEXT>`
Category
  Read Access

### lock

public long lock(CONTEXT context, Collection<? extends OBJECT> objects, IRWLockManager.LockType lockType, int count, long timeout, IRWOLockManager.LockDeltaHandler<OBJECT,CONTEXT> deltaHandler, Consumer<RWOLockManager.LockState<OBJECT,CONTEXT>> stateHandler) throws InterruptedException, TimeoutRuntimeException
Beschreibung aus Schnittstelle kopiert: `IRWOLockManager`
Adds locks of the given lockType, owned by the given context to the given objects.

Angegeben von:
  `lock` in Schnittstelle `IRWOLockManager<OBJECT,CONTEXT>`
Parameter:
  `context` - The lock context to add from the `objects`. Must not be `null`.
  `objects` - The objects to lock. Must not be `null`.
  `lockType` - The type of lock to add to the `objects`. Must not be `null`.
  `count` - The number of locks to add to each of the `objects`.
  `timeout` - The period in milliseconds after that a `TimeoutRuntimeException` is thrown if some or all of the `objects` could not be locked, or `IRWOLockManager.NO_TIMEOUT` to attempt forever to acquire the requested locks.
  `deltaHandler` - A handler that is notified with each delta in a `lock state`, or `null` if no such notification is needed. The handler is notified at most once per delta, but it can happen that the handler is notified before the lock operation finally fails with one of the specified exceptions. The notification handling should be fast because notifications occur while the calling thread is synchronized on this lock manager.
  `stateHandler` - A handler that is notified with each new `lock state`, or `null` if no such notification is needed.. The handler is notified at most once per lock state, but it can happen that the handler is notified before the lock operation finally fails with one of the specified exceptions. The notification handling should be fast because notifications occur while the calling thread is synchronized on this lock manager.
Gibt zurück:
  The new `modification count`.
Löst aus:
  `InterruptedException` - If the calling thread is interrupted.
  `TimeoutRuntimeException` - If the timeout period has expired and some or all of the `objects` could not be locked.
Seit:
  3.16
Category
  Write Access

### unlock

public long unlock(CONTEXT context, Collection<? extends OBJECT> objects, IRWLockManager.LockType lockType, int count, IRWOLockManager.LockDeltaHandler<OBJECT,CONTEXT> deltaHandler, Consumer<RWOLockManager.LockState<OBJECT,CONTEXT>> stateHandler)
Beschreibung aus Schnittstelle kopiert: `IRWOLockManager`
Removes locks of the given lockType, owned by the given context from the given objects.

Angegeben von:
  `unlock` in Schnittstelle `IRWOLockManager<OBJECT,CONTEXT>`
Parameter:
  `context` - The lock context to remove from the `objects`. Must not be `null`.
  `objects` - The objects to unlock, or `IRWOLockManager.ALL_OBJECTS` to unlock all objects of the `context`.
  `lockType` - The type of lock to remove from the `objects`, or `IRWOLockManager.ALL_LOCK_TYPES` to remove the locks of all types.
  `count` - The number of locks to remove from each of the `objects`, or `IRWOLockManager.ALL_LOCKS` to remove all locks.
  `deltaHandler` - A handler that is notified with each delta in a `RWOLockManager.LockState`, or `null` if no such notification is needed.
  `stateHandler` - A handler that is notified with each new `RWOLockManager.LockState`, or `null` if no such notification is needed.
Category
  Write Access

### hasLock

public boolean hasLock(IRWLockManager.LockType type, CONTEXT context, OBJECT objectToLock)

Angegeben von:
  `hasLock` in Schnittstelle `IRWLockManager<OBJECT,CONTEXT>`
Category
  Read Access

### hasLockByOthers

public boolean hasLockByOthers(IRWLockManager.LockType type, CONTEXT context, OBJECT objectToLock)

Angegeben von:
  `hasLockByOthers` in Schnittstelle `IRWLockManager<OBJECT,CONTEXT>`
Category
  Read Access

### getLockState

public RWOLockManager.LockState<OBJECT,CONTEXT> getLockState(OBJECT key)

Category
  Read Access

### getLockStates

public void getLockStates(Collection<OBJECT> keys, BiConsumer<OBJECT,RWOLockManager.LockState<OBJECT,CONTEXT>> consumer)

Seit:
  3.16
Category
  Read Access

### getLockStates

public void getLockStates(Consumer<RWOLockManager.LockState<OBJECT,CONTEXT>> consumer)

Seit:
  3.16
Category
  Read Access

### changeContext

protected void changeContext(CONTEXT oldContext, CONTEXT newContext)

### getObjectToLocksMap

protected final Map<OBJECT,RWOLockManager.LockState<OBJECT,CONTEXT>> getObjectToLocksMap()
All access to the returned map must be properly synchronized on this `RWOLockManager`.

### getContextToLocksMap

protected final Map<CONTEXT,Set<RWOLockManager.LockState<OBJECT,CONTEXT>>> getContextToLocksMap()
All access to the returned map must be properly synchronized on this `RWOLockManager`.

### createObjectToLocksMap

protected Map<OBJECT,RWOLockManager.LockState<OBJECT,CONTEXT>> createObjectToLocksMap()

### createContextToLocksMap

protected Map<CONTEXT,Set<RWOLockManager.LockState<OBJECT,CONTEXT>>> createContextToLocksMap()

### currentTimeMillis

protected long currentTimeMillis()

### getLockStates

@Deprecated public List<RWOLockManager.LockState<OBJECT,CONTEXT>> getLockStates()
Veraltet.

### setLockState

@Deprecated public void setLockState(OBJECT key, RWOLockManager.LockState<OBJECT,CONTEXT> lockState)
Veraltet.

Category
  Write Access

### lock

@Deprecated public void lock(IRWLockManager.LockType type, CONTEXT context, Collection<? extends OBJECT> objectsToLock, long timeout) throws InterruptedException
Veraltet.

Angegeben von:
  `lock` in Schnittstelle `IRWLockManager<OBJECT,CONTEXT>`
Angegeben von:
  `lock` in Schnittstelle `IRWOLockManager<OBJECT,CONTEXT>`
Löst aus:
  `InterruptedException`

### lock2

@Deprecated public List<RWOLockManager.LockState<OBJECT,CONTEXT>> lock2(IRWLockManager.LockType type, CONTEXT context, Collection<? extends OBJECT> objectsToLock, long timeout) throws InterruptedException
Veraltet.

Angegeben von:
  `lock2` in Schnittstelle `IRWOLockManager<OBJECT,CONTEXT>`
Löst aus:
  `InterruptedException`

### lock

@Deprecated public void lock(IRWLockManager.LockType type, CONTEXT context, OBJECT objectToLock, long timeout) throws InterruptedException
Veraltet.

Angegeben von:
  `lock` in Schnittstelle `IRWLockManager<OBJECT,CONTEXT>`
Angegeben von:
  `lock` in Schnittstelle `IRWOLockManager<OBJECT,CONTEXT>`
Löst aus:
  `InterruptedException`

### unlock

@Deprecated public void unlock(IRWLockManager.LockType type, CONTEXT context, Collection<? extends OBJECT> objectsToUnlock)
Veraltet.
Beschreibung aus Schnittstelle kopiert: `IRWLockManager`
Attempts to release for a given lock type, context and objects.

Angegeben von:
  `unlock` in Schnittstelle `IRWLockManager<OBJECT,CONTEXT>`
Angegeben von:
  `unlock` in Schnittstelle `IRWOLockManager<OBJECT,CONTEXT>`

### unlock

@Deprecated public void unlock(CONTEXT context)
Veraltet.
Beschreibung aus Schnittstelle kopiert: `IRWLockManager`
Attempts to release all locks(read and write) for a given context.

Angegeben von:
  `unlock` in Schnittstelle `IRWLockManager<OBJECT,CONTEXT>`
Angegeben von:
  `unlock` in Schnittstelle `IRWOLockManager<OBJECT,CONTEXT>`

### unlock2

@Deprecated public List<RWOLockManager.LockState<OBJECT,CONTEXT>> unlock2(CONTEXT context)
Veraltet.

Angegeben von:
  `unlock2` in Schnittstelle `IRWOLockManager<OBJECT,CONTEXT>`

### unlock2

@Deprecated public List<RWOLockManager.LockState<OBJECT,CONTEXT>> unlock2(CONTEXT context, Collection<? extends OBJECT> objectsToUnlock)
Veraltet.

Angegeben von:
  `unlock2` in Schnittstelle `IRWOLockManager<OBJECT,CONTEXT>`

### unlock2

@Deprecated public List<RWOLockManager.LockState<OBJECT,CONTEXT>> unlock2(IRWLockManager.LockType lockType, CONTEXT context, Collection<? extends OBJECT> objectsToUnlock)
Veraltet.

Angegeben von:
  `unlock2` in Schnittstelle `IRWOLockManager<OBJECT,CONTEXT>`

### setUnlockAll

@Deprecated public static void setUnlockAll(boolean on)
Veraltet.