Class DelegableReentrantLock
java.lang.Object
org.eclipse.net4j.util.concurrent.NonFairReentrantLock
org.eclipse.net4j.util.concurrent.DelegableReentrantLock
- All Implemented Interfaces:
Serializable,Lock,IManagedContainerProvider,INotifier,IDeactivateable,ILifecycle
public class DelegableReentrantLock
extends NonFairReentrantLock
implements ILifecycle, IManagedContainerProvider
A reentrant lock that can be delegated to other threads as detected by
delegate detectors.
Delegate detectors can be registered programmatically or discovered in a managed container.
The plugin container is used by default.
This class implements ILifecycle and must be activated before use. As a consequence, it
also implements INotifier, but it does not send any events.
- Since:
- 3.6
- Author:
- Eike Stepper
- See Also:
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from interface org.eclipse.net4j.util.lifecycle.ILifecycle
ILifecycle.DeferrableActivationNested classes/interfaces inherited from interface org.eclipse.net4j.util.event.INotifier
INotifier.INotifier2 -
Constructor Summary
ConstructorsConstructorDescriptionConstructs a delegable reentrant lock that uses theplugin containerto discoverdelegate detectors.DelegableReentrantLock(boolean usePluginContainer) Constructs a delegable reentrant lock that uses theplugin containerto discoverdelegate detectorsif the given flag istrue.DelegableReentrantLock(IManagedContainer container) Constructs a delegable reentrant lock that uses the givenmanaged containerto discoverdelegate detectors. -
Method Summary
Modifier and TypeMethodDescriptionfinal voidactivate()final voidaddDelegateDetector(DelegableReentrantLock.DelegateDetector delegateDetector) final voidaddListener(IListener listener) Adds a listener to this notifier.final Exceptionfinal IManagedContainerfinal LifecycleStatefinal IListener[]Returns the listeners that are registered with this notifier.final booleanReturnstrueif one or more listeners are registered with this notifier,falseotherwise.final booleanisActive()protected booleanisDelegate(Thread thread, Thread owner) protected booleanfinal voidremoveDelegateDetector(DelegableReentrantLock.DelegateDetector delegateDetector) final voidremoveListener(IListener listener) Removes a listener from this notifier.Methods inherited from class org.eclipse.net4j.util.concurrent.NonFairReentrantLock
getHoldCount, getOwner, getQueuedThreads, getQueueLength, getWaitingThreads, getWaitQueueLength, hasQueuedThread, hasQueuedThreads, hasWaiters, isHeldByCurrentThread, isLocked, lock, lockInterruptibly, newCondition, toString, tryLock, tryLock, unlock
-
Constructor Details
-
DelegableReentrantLock
Constructs a delegable reentrant lock that uses the givenmanaged containerto discoverdelegate detectors. If the given container isnull, no container is used. -
DelegableReentrantLock
public DelegableReentrantLock(boolean usePluginContainer) Constructs a delegable reentrant lock that uses theplugin containerto discoverdelegate detectorsif the given flag istrue. Uses no container otherwise.- Since:
- 3.29
-
DelegableReentrantLock
public DelegableReentrantLock()Constructs a delegable reentrant lock that uses theplugin containerto discoverdelegate detectors.
-
-
Method Details
-
addDelegateDetector
- Since:
- 3.29
-
removeDelegateDetector
- Since:
- 3.29
-
getContainer
- Specified by:
getContainerin interfaceIManagedContainerProvider
-
activate
- Specified by:
activatein interfaceILifecycle- Throws:
LifecycleException
-
deactivate
- Specified by:
deactivatein interfaceIDeactivateable- Specified by:
deactivatein interfaceILifecycle
-
getLifecycleState
- Specified by:
getLifecycleStatein interfaceILifecycle
-
isActive
public final boolean isActive()- Specified by:
isActivein interfaceILifecycle
-
addListener
Description copied from interface:INotifierAdds a listener to this notifier.Depending on the implementation duplicate listeners may lead to duplicate event delivery or not. Implementors are encouraged to prevent events from being delivered more than once to the same listener,
- Specified by:
addListenerin interfaceINotifier
-
removeListener
Description copied from interface:INotifierRemoves a listener from this notifier.- Specified by:
removeListenerin interfaceINotifier
-
getListeners
Description copied from interface:INotifierReturns the listeners that are registered with this notifier.Depending on the implementation duplicate listeners may be contained in the returned array.
- Specified by:
getListenersin interfaceINotifier
-
hasListeners
public final boolean hasListeners()Description copied from interface:INotifierReturnstrueif one or more listeners are registered with this notifier,falseotherwise.- Specified by:
hasListenersin interfaceINotifier
-
isOwner
- Overrides:
isOwnerin classNonFairReentrantLock
-
isDelegate
-