TKMCancellationTokenSource
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()
See also
TKMCancellationToken
See also
TKMPromise<T>
-
Creates a new cancellation token source.
Declaration
Swift
public init()
-
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.Declaration
Swift
public init(cancellationRequested: Bool)
Parameters
cancellationRequested
true, if cancellation is to be requested and false, if not.
-
Returns the
TKMCancellationToken
associated with this instance.Declaration
Swift
public var token: TKMCancellationToken { get }
-
Requests cancellation of the affected promises.
Declaration
Swift
public func requestCancellation()