public class TKMCancellationTokenSource
This class provides functionality to cancel pending promises. It is a source for cancellation tokens.
The example below demonstrates how to retrieve a CancellationToken and use it to cancel a pending operation.
let cancellationTokenSource = TKMCancellationTokenSource() let ct = cancellationTokenSource.token //Pass the token to an asynchronous operation that accepts a CancellationToken asyncOperation(..., ct).conclude() // If required, cancellation can be requested as follows: cancellationTokenSource.requestCancellation()
Creates a new cancellation token source.
Creates a new cancellation token source with cancellation already requested. This eliminates the need to call
requestCancellation()after instantiation if cancellation is to be requested at instantiation time.
public init(cancellationRequested: Bool)
true, if cancellation is to be requested and false, if not.
Requests cancellation of the affected promises.
public func requestCancellation()