public boolean await(final long milliseconds) throws InterruptedException { return control.tryAcquireSharedNanos(1, TimeUnit.MILLISECONDS.toNanos(milliseconds)); }
@Override public boolean tryReleaseShared(final int numberOfReleases) { for (;;) { int actualState = getState(); if (actualState == 0) { return true; } int newState = actualState - numberOfReleases; if (newState < 0) { newState = 0; } if (compareAndSetState(actualState, newState)) { return newState == 0; } } } }
@Override public boolean tryReleaseShared(final int numberOfReleases) { for (;;) { int actualState = getState(); if (actualState == 0) { return true; } int newState = actualState - numberOfReleases; if (newState < 0) { newState = 0; } if (compareAndSetState(actualState, newState)) { return newState == 0; } } } }
@Override public boolean tryReleaseShared(final int numberOfReleases) { for (;;) { int actualState = getState(); if (actualState == 0) { return true; } int newState = actualState - numberOfReleases; if (newState < 0) { newState = 0; } if (compareAndSetState(actualState, newState)) { return newState == 0; } } } }
@Override public boolean tryReleaseShared(final int numberOfReleases) { for (;;) { int actualState = getState(); if (actualState == 0) { return true; } int newState = actualState - numberOfReleases; if (newState < 0) { newState = 0; } if (compareAndSetState(actualState, newState)) { return newState == 0; } } } }
@Override public boolean tryReleaseShared(final int numberOfReleases) { for (;;) { int actualState = getState(); if (actualState == 0) { return true; } int newState = actualState - numberOfReleases; if (newState < 0) { newState = 0; } if (compareAndSetState(actualState, newState)) { return newState == 0; } } } }
@Override public boolean tryReleaseShared(final int numberOfReleases) { for (;;) { int actualState = getState(); if (actualState == 0) { return true; } int newState = actualState - numberOfReleases; if (newState < 0) { newState = 0; } if (compareAndSetState(actualState, newState)) { return newState == 0; } } } }
public void await() throws InterruptedException { control.acquireSharedInterruptibly(1); }
public void countUp() { control.add(); }
public int getCount() { return control.getCount(); }
public ReusableLatch(final int count) { control = new CountSync(count); }
private CountSync(int count) { setState(count); }
public void countUp() { control.add(); }
public void countDown(final int count) { control.releaseShared(count); }
public boolean await(final long milliseconds) throws InterruptedException { return control.tryAcquireSharedNanos(1, TimeUnit.MILLISECONDS.toNanos(milliseconds)); }
private CountSync(int count) { setState(count); }
public int getCount() { return control.getCount(); }
public ReusableLatch(final int count) { control = new CountSync(count); }
public void countDown() { control.releaseShared(1); }
public void countUp() { control.add(); }