@InterfaceAudience.Private public class DrainBarrier extends Object
Modifier and Type | Field and Description |
---|---|
private static long |
DRAINING_FLAG |
private static int |
FLAG_BIT_COUNT |
private AtomicLong |
valueAndFlags
Contains the number of outstanding operations, as well as flags.
|
Constructor and Description |
---|
DrainBarrier() |
Modifier and Type | Method and Description |
---|---|
boolean |
beginOp()
Tries to start an operation.
|
private static long |
dec(long valueAndFlags) |
void |
endOp()
Ends the operation.
|
private static long |
getValue(long valueAndFlags) |
private static long |
inc(long valueAndFlags) |
private static boolean |
isDraining(long valueAndFlags) |
void |
stopAndDrainOps()
Blocks new operations from starting, waits for the current ones to drain.
|
private void |
stopAndDrainOps(boolean ignoreRepeatedCalls) |
void |
stopAndDrainOpsOnce()
Blocks new operations from starting, waits for the current ones to drain.
|
private final AtomicLong valueAndFlags
private static final long DRAINING_FLAG
private static final int FLAG_BIT_COUNT
public boolean beginOp()
public void endOp()
public void stopAndDrainOps() throws InterruptedException
InterruptedException
- the wait for operations has been interrupted.public void stopAndDrainOpsOnce() throws InterruptedException
InterruptedException
- the wait for operations has been interrupted.private void stopAndDrainOps(boolean ignoreRepeatedCalls) throws InterruptedException
ignoreRepeatedCalls
- If this is true and somebody already called stop, this method
will return immediately if true; if this is false and somebody
already called stop, it will assert.InterruptedException
private static final boolean isDraining(long valueAndFlags)
private static final long getValue(long valueAndFlags)
private static final long inc(long valueAndFlags)
private static final long dec(long valueAndFlags)
Copyright © 2007–2019 The Apache Software Foundation. All rights reserved.