org.objectweb.dream.synchro
Class BasicMutexImpl
java.lang.Object
org.objectweb.dream.AbstractComponent
org.objectweb.dream.synchro.BasicMutexImpl
- All Implemented Interfaces:
- BindingController, LifeCycleController, Loggable, Mutex
- public class BasicMutexImpl
- extends AbstractComponent
- implements Mutex
Basic implementation of the Mutex
interface. This implementation is
unsafe, i.e. the identity of components acquiring/releasing the Mutex is
unknown. As a consequence, the acquired mutex can be released by every
component.
Inspired by Doug Lea's implementation.
Field Summary |
protected boolean |
inuse
The lock status. |
Method Summary |
String[] |
listFc()
|
void |
lock()
Acquires the mutex. |
boolean |
timedLock(long msecs)
Tries to acquire the mutex. |
void |
unlock()
Releases the mutex. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
inuse
protected boolean inuse
- The lock status.
BasicMutexImpl
public BasicMutexImpl()
lock
public void lock()
throws InterruptedException
- Description copied from interface:
Mutex
- Acquires the mutex.
- Specified by:
lock
in interface Mutex
- Throws:
InterruptedException
- the thread is interrupted.- See Also:
Mutex.lock()
timedLock
public boolean timedLock(long msecs)
throws InterruptedException
- Description copied from interface:
Mutex
- Tries to acquire the mutex.
- Specified by:
timedLock
in interface Mutex
- Parameters:
msecs
- the number of milliseconds to wait for the lock.
- Returns:
true
if the lock is acquired, false
otherwise.
- Throws:
InterruptedException
- if the thread is interrupted.- See Also:
Mutex.timedLock(long)
unlock
public void unlock()
- Description copied from interface:
Mutex
- Releases the mutex.
- Specified by:
unlock
in interface Mutex
- See Also:
Mutex.unlock()
listFc
public String[] listFc()
- Specified by:
listFc
in interface BindingController
- See Also:
BindingController.listFc()
Copyright © 2003, 2004 - INRIA Rhone-Alpes - All Rights Reserved.