public class WorkerMetaLock extends Object implements Lock
MasterWorkerInfo
properly.
As mentioned in javadoc of MasterWorkerInfo
, there are multiple groups of metadata
that requires external locking. This class is used to provide a clean interface to manage
the locking logic and lock life cycles.
When multiple WorkerMetaLockSection
are specified, internally the locks will be
locked in order, and unlocked in the opposite order, so that deadlock is prevented.
This class implements Lock
so it can be managed by
LockResource
. Callers do not need to lock and unlock explicitly.Modifier and Type | Method and Description |
---|---|
void |
lock() |
void |
lockInterruptibly() |
Condition |
newCondition() |
boolean |
tryLock() |
boolean |
tryLock(long time,
TimeUnit unit) |
void |
unlock() |
public void lockInterruptibly() throws InterruptedException
lockInterruptibly
in interface Lock
InterruptedException
public boolean tryLock(long time, TimeUnit unit) throws InterruptedException
tryLock
in interface Lock
InterruptedException
public Condition newCondition()
newCondition
in interface Lock
Copyright © 2023. All Rights Reserved.