@Test public void testDotoInvalid() throws Exception { setupDoto(false, false); assertEquals(new ImmediateCancelled<>(caller), underTest.doto(action)); verifyDoto(false, false); }
@Override public <R> Stage<R> doto( final Function<? super T, ? extends Stage<R>> action ) { final Borrowed<T> b = borrow(); if (!b.isValid()) { return new ImmediateCancelled<>(caller); } final T reference = b.get(); final Stage<R> f; try { f = action.apply(reference); } catch (final Exception e) { b.release(); return new ImmediateFailed<>(caller, e); } return f.whenDone(b::release); }
ConcurrentManaged implements Managed<T> { @Override public <R> Stage<R> doto( final Function<? super T, ? extends Stage<R>> action ) { final Borrowed<T> b = borrow(); if (!b.isValid()) { return new ImmediateCancelled<>(caller); } final T reference = b.get(); final Stage<R> f; try { f = action.apply(reference); } catch (final Exception e) { b.release(); return new ImmediateFailed<>(caller, e); } return f.whenDone(b::release); } }
ConcurrentManaged implements Managed<T> { @Override public <R> Stage<R> doto( final Function<? super T, ? extends Stage<R>> action ) { final Borrowed<T> b = borrow(); if (!b.isValid()) { return new ImmediateCancelled<>(caller); } final T reference = b.get(); final Stage<R> f; try { f = action.apply(reference); } catch (final Exception e) { b.release(); return new ImmediateFailed<>(caller, e); } return f.whenDone(b::release); } 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 <R> Stage<R> doto( final Function<? super T, ? extends Stage<R>> action ) { final Borrowed<T> b = borrow(); if (!b.isValid()) { return new ImmediateCancelled<>(caller); } final T reference = b.get(); final Stage<R> f; try { f = action.apply(reference); } catch (final Exception e) { b.release(); return new ImmediateFailed<>(caller, e); } return f.whenDone(b::release); } 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 <R> Stage<R> doto( final Function<? super T, ? extends Stage<R>> action ) { final Borrowed<T> b = borrow(); if (!b.isValid()) { return new ImmediateCancelled<>(caller); } final T reference = b.get(); final Stage<R> f; try { f = action.apply(reference); } catch (final Exception e) { b.release(); return new ImmediateFailed<>(caller, e); } return f.whenDone(b::release); } 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();  }