@InterfaceAudience.Private public class IdLock extends Object
IdLock.Entry lockEntry = idLock.getLockEntry(id); try { // User code. } finally { idLock.releaseLockEntry(lockEntry); }
Modifier and Type | Class and Description |
---|---|
static class |
IdLock.Entry
An entry returned to the client as a lock object
|
Constructor and Description |
---|
IdLock() |
Modifier and Type | Method and Description |
---|---|
IdLock.Entry |
getLockEntry(long id)
Blocks until the lock corresponding to the given id is acquired.
|
void |
releaseLockEntry(IdLock.Entry entry)
Must be called in a finally block to decrease the internal counter and
remove the monitor object for the given id if the caller is the last
client.
|
void |
waitForWaiters(long id,
int numWaiters) |
public IdLock.Entry getLockEntry(long id) throws IOException
id
- an arbitrary number to lock onreleaseLockEntry(Entry)
to release
the lockIOException
- if interruptedpublic void releaseLockEntry(IdLock.Entry entry)
entry
- the return value of getLockEntry(long)
public void waitForWaiters(long id, int numWaiters) throws InterruptedException
InterruptedException
Copyright © 2007-2016 The Apache Software Foundation. All Rights Reserved.