Package org.agrona.concurrent
Class NoOpLock
- java.lang.Object
-
- org.agrona.concurrent.NoOpLock
-
- All Implemented Interfaces:
java.util.concurrent.locks.Lock
public final class NoOpLock extends java.lang.Object implements java.util.concurrent.locks.Lock
ALock
implementation that is a no operation, i.e. it effectively does nothing.Useful for effectively eliding a lock in a single threaded environment.
-
-
Constructor Summary
Constructors Constructor Description NoOpLock()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
lock()
Proceeds as if the lock has been acquired.void
lockInterruptibly()
Proceeds as if the lock has been acquired.java.util.concurrent.locks.Condition
newCondition()
Not supported.boolean
tryLock()
Always succeeds.boolean
tryLock(long time, java.util.concurrent.TimeUnit unit)
Always succeeds.void
unlock()
The lock has never been taken so no effect.
-
-
-
Field Detail
-
INSTANCE
public static final NoOpLock INSTANCE
As there is no instance state then this object can be used to save on allocation.
-
-
Method Detail
-
lock
public void lock()
Proceeds as if the lock has been acquired.- Specified by:
lock
in interfacejava.util.concurrent.locks.Lock
-
lockInterruptibly
public void lockInterruptibly()
Proceeds as if the lock has been acquired.- Specified by:
lockInterruptibly
in interfacejava.util.concurrent.locks.Lock
-
tryLock
public boolean tryLock()
Always succeeds.- Specified by:
tryLock
in interfacejava.util.concurrent.locks.Lock
- Returns:
- always true.
-
tryLock
public boolean tryLock(long time, java.util.concurrent.TimeUnit unit)
Always succeeds.- Specified by:
tryLock
in interfacejava.util.concurrent.locks.Lock
- Parameters:
time
- which is ignored.unit
- which is ignored.- Returns:
- always true.
-
unlock
public void unlock()
The lock has never been taken so no effect.- Specified by:
unlock
in interfacejava.util.concurrent.locks.Lock
-
newCondition
public java.util.concurrent.locks.Condition newCondition()
Not supported.- Specified by:
newCondition
in interfacejava.util.concurrent.locks.Lock
- Returns:
- never returns.
- Throws:
java.lang.UnsupportedOperationException
- if used.
-
-