(wangle) Interrupts (and therefore, cancellation)
authorHans Fugal <fugalh@fb.com>
Tue, 21 Oct 2014 17:24:10 +0000 (10:24 -0700)
committerdcsommer <dcsommer@fb.com>
Wed, 29 Oct 2014 23:03:07 +0000 (16:03 -0700)
commit831405dc6952742e29fb030d870608fab8830f1a
tree9eba647fe4eaee481d689e0ee659b7cac608e663
parent1be516d1df75d5c33f9b064c288f1e8533f5c8c3
(wangle) Interrupts (and therefore, cancellation)

Summary:
Modeled very closely after Finagle's interrupts. Compare with https://github.com/twitter/util/blob/master/util-core/src/main/scala/com/twitter/util/Promise.scala if you like.
The basic idea is the promise holder can register an interrupt handler, and then interrupts will call that handler. A typical handler would fulfil the promise with an exception (or special value) indicating that it was interrupted (if it was interrupted in time).
Raising an interrupt does not prevent setting a value or callbacks executing or any of that - it is only advisory to the promise holder.

Test Plan: I wrote some unit tests.

Reviewed By: davejwatson@fb.com

Subscribers: folly-diffs@, net-systems@, fugalh, exa, hannesr, njormrod

FB internal diff: D1620805

Tasks: 4618297
folly/wangle/Future-inl.h
folly/wangle/Future.h
folly/wangle/Promise-inl.h
folly/wangle/Promise.h
folly/wangle/WangleException.h
folly/wangle/detail/Core.h
folly/wangle/test/Interrupts.cpp [new file with mode: 0644]