@Override public void close() { if (!this.closed.getAndSet(true)) { Futures.await(Services.stopAsync(this, executorService())); ReusableLatch signal = this.closeReleaseSignal; if (signal != null) { // Wait until we are told to complete. signal.awaitUninterruptibly(); } } }
@Override protected void doStop() { executorService().execute(() -> { ReusableLatch signal = this.stopSignal; if (signal != null) { // Wait until we are told to stop. signal.awaitUninterruptibly(); } if (state() != State.FAILED && state() != State.TERMINATED && this.stopException != null) { notifyFailed(this.stopException); } else { notifyStopped(); } }); }
@Override public RevisionedImpl create(String scopedSteamName, Revision revision) { latch.awaitUninterruptibly(); return new RevisionedImpl(scopedSteamName, new RevisionImpl(revision.asImpl().getSegment(), num, num), String.valueOf(num)); }
@Test(timeout = 5000) public void testRelease() { ReusableLatch latch = new ReusableLatch(false); AssertExtensions.assertBlocks(() -> latch.awaitUninterruptibly(), () -> latch.release()); }
@Override public RevisionedImpl applyTo(RevisionedImpl oldState, Revision newRevision) { latch.awaitUninterruptibly(); return new RevisionedImpl(oldState.scopedStreamName, new RevisionImpl(newRevision.asImpl().getSegment(), num, num), "" + num); } }