@Test public void testStop() { underTest.state.set(ConcurrentManaged.ManagedState.STARTED); underTest.reference.set(reference); assertEquals(stopFuture, underTest.stop()); assertNull(underTest.reference.get()); verify(underTest).release(); }
@Override public Stage<Void> stop() { if (!state.compareAndSet(ManagedState.STARTED, ManagedState.STOPPED)) { return stopFuture; } stopReferenceFuture.complete(this.reference.getAndSet(null)); release(); return stopFuture; }
ConcurrentManaged implements Managed<T> { @Override public Stage<Void> stop() { if (!state.compareAndSet(ManagedState.STARTED, ManagedState.STOPPED)) { return stopFuture; } stopReferenceFuture.complete(this.reference.getAndSet(null)); release(); return stopFuture; } }
ConcurrentManaged implements Managed<T> { @Override public Stage<Void> stop() { if (!state.compareAndSet(ManagedState.STARTED, ManagedState.STOPPED)) { return stopFuture; } stopReferenceFuture.complete(this.reference.getAndSet(null)); release(); return stopFuture; } ConcurrentManaged(
      final Caller caller, final ManagedOptions options, final Supplier<? extends Stage<T>> setup,
      final Completable<Void> startFuture, final Completable<Void> zeroLeaseFuture,
      final Completable<T> stopReferenceFuture, final Stage<Void> stopFuture
  ); }
ConcurrentManaged implements Managed<T> { @Override public Stage<Void> stop() { if (!state.compareAndSet(ManagedState.STARTED, ManagedState.STOPPED)) { return stopFuture; } stopReferenceFuture.complete(this.reference.getAndSet(null)); release(); return stopFuture; } ConcurrentManaged(
      final Caller caller, final ManagedOptions options, final Supplier<? extends Stage<T>> setup,
      final Completable<Void> startFuture, final Completable<Void> zeroLeaseFuture,
      final Completable<T> stopReferenceFuture, final Stage<Void> stopFuture
  ); static ConcurrentManaged<T> newManaged(
      final Async async, final Caller caller, final ManagedOptions options,
      final Supplier<? extends Stage<T>> setup,
      final Function<? super T, ? extends Stage<Void>> teardown
  ); @Override Stage<R> doto(
      final Function<? super T, ? extends Stage<R>> action
  ); @Override Borrowed<T> borrow(); @Override boolean isReady(); @Override Stage<Void> start(); @Override Stage<Void> stop(); @Override String toString(); }
ConcurrentManaged implements Managed<T> { @Override public Stage<Void> stop() { if (!state.compareAndSet(ManagedState.STARTED, ManagedState.STOPPED)) { return stopFuture; } stopReferenceFuture.complete(this.reference.getAndSet(null)); release(); return stopFuture; } ConcurrentManaged(
      final Caller caller, final ManagedOptions options, final Supplier<? extends Stage<T>> setup,
      final Completable<Void> startFuture, final Completable<Void> zeroLeaseFuture,
      final Completable<T> stopReferenceFuture, final Stage<Void> stopFuture
  ); static ConcurrentManaged<T> newManaged(
      final Async async, final Caller caller, final ManagedOptions options,
      final Supplier<? extends Stage<T>> setup,
      final Function<? super T, ? extends Stage<Void>> teardown
  ); @Override Stage<R> doto(
      final Function<? super T, ? extends Stage<R>> action
  ); @Override Borrowed<T> borrow(); @Override boolean isReady(); @Override Stage<Void> start(); @Override Stage<Void> stop(); @Override String toString();  }