A CancellationSource object provides the ability to request cancellation of operations that an associated CancellationToken was passed to.
Declared in <folly/CancellationToken.h>
class CancellationSource;
Example usage:
CancellationSource cs; Future<void> f = startSomeOperation(cs.getToken());
// Later... cs.requestCancellation();
refcode folly/docs/examples/folly/CancellationSource.cpp
| Name | Description |
|---|---|
CancellationSource [constructor] | Constructors |
operator= | Assignment operators |
canBeCancelled | Query if cancellation can be requested through this CancellationSource object. This will only return false if the CancellationSource object has been moved-from. |
getToken | Obtain a CancellationToken linked to this CancellationSource. |
isCancellationRequested | Query if cancellation has already been requested on this CancellationSource or any other CancellationSource object copied from the same original CancellationSource object. |
requestCancellation | Request cancellation of work associated with this CancellationSource. |
swap | Swaps the underlying state of the cancellation source with the source that is passed-in. |
| Name | Description |
|---|---|
create | Returns a pair of <CancellationSource, Data> where the underlying state is created using the arguments that is passed-in. |
invalid | Construct a CancellationSource that cannot be cancelled. |
| Name | Description |
|---|---|
folly::operator== | Return whether two sources share the same underlying cancellation state. |
| Name | Description |
|---|---|
operator!= | Return whether two sources do not share the same underlying cancellation state. |