public void DerefThrowsAfterCancellation() { AFnImpl fn = new AFnImpl(); fn._fn0 = () => { while (true); }; Future f = new Future(fn); f.cancel(); f.deref(); }
public void CancelAbortsTheTask() { AFnImpl fn = new AFnImpl(); fn._fn0 = () => { while (true); }; Future f = new Future(fn); Expect(f.isCancelled(), EqualTo(false)); Expect(f.cancel(true), EqualTo(true)); Expect(f.isCancelled(), EqualTo(true)); }
public void CancelFailsAfterSuccessfulCompletion() { AFnImpl fn = new AFnImpl(); fn._fn0 = () => { return 42; }; Future f = new Future(fn); Expect(f.deref(), EqualTo(42)); Expect(f.cancel(), EqualTo(false)); Expect(f.isCancelled(), EqualTo(false)); }
public void SecondCancelReturnsFalse() { AFnImpl fn = new AFnImpl(); fn._fn0 = () => { while (true); }; Future f = new Future(fn); Expect(f.cancel(true), EqualTo(true)); Expect(f.cancel(true), EqualTo(false)); }