Other Classes
The following classes are available globally.
-
Keeps track of all promises in a promise chain with pending or currently running tasks, and cancels them all when
See morecancel
is called.Declaration
Swift
public class CancelContext : Hashable
-
Tracks the cancel items for a CancellablePromise. These items are removed from the associated CancelContext when the promise resolves.
Declaration
Swift
public class CancelItemList
-
Undocumented
See moreDeclaration
Swift
public class CancelContextFinalizer
-
Cancellable finalizer returned from
See morecatch
. Usefinally
to specify a code block that executes when the promise chain resolves.Declaration
Swift
public class CancellableFinalizer : CancelContextFinalizer
extension CancellableFinalizer: _PMKFinallyWrappers
-
Undocumented
See moreDeclaration
Swift
public class CancellableCascadingFinalizer : CancelContextFinalizer
extension CancellableCascadingFinalizer: _PMKCatchWrappers
-
A
CancellablePromise
is a functional abstraction around a failable and cancellable asynchronous operation.At runtime the promise can become a member of a chain of promises, where the
See morecancelContext
is used to track and cancel (if desired) all promises in this chain.Declaration
Swift
public class CancellablePromise<T> : CancellableThenable, CancellableCatchMixin
extension CancellablePromise: _PMKSharedWrappers
extension CancellablePromise: _PMKCatchWrappers
extension CancellablePromise: _PMKSharedVoidWrappers where C.T == Void
-
Undocumented
See moreDeclaration
-
Undocumented
See moreDeclaration
-
A PromiseKit Dispatcher that allows no more than X simultaneous executions at once.
See moreDeclaration
Swift
public final class ConcurrencyLimitedDispatcher : Dispatcher
-
A
PromiseKit
Dispatcher
that dispatches X closures every Y seconds, on average.This implementation is O(1) in both space and time, but it uses approximate time accounting. Over the long term, the rate converges to a rate of X/Y, but the transient burst rate will be up to 2X/Y in some situations.
For a completely accurate rate limiter that dispatches as rapidly as possible, see
StrictRateLimitedDispatcher
. That implementation requires additional storage.Executions are paced by start time, not by completion, so it’s possible to end up with more than X closures running concurrently in some circumstances.
There is no guarantee that you will reach a given dispatch rate. There are not an infinite number of threads available, and GCD scheduling has limited accuracy.
100% thread safe.
See moreDeclaration
Swift
public final class RateLimitedDispatcher : RateLimitedDispatcherBase
-
Undocumented
See moreDeclaration
Swift
public class RateLimitedDispatcherBase : Dispatcher
-
A
PromiseKit
Dispatcher
that dispatches no more than X closures every Y seconds. This is a sliding window, so executions occur as rapidly as possible without exceeding X in any Y-second period.This version implements perfectly accurate timing, so it must (temporarily) track up to X previous execution times and is thus O(X) in space.
For a “pretty good” approach to rate limiting that does not consume additional storage, see
RateLimitedDispatcher
.Executions are paced by start time, not by completion, so it’s possible to end up with more than X closures running concurrently in some circumstances.
There is no guarantee that you will reach a given dispatch rate. There are not an infinite number of threads available, and GCD scheduling has limited accuracy. The only guarantee is that dispatching will never exceed the requested rate.
100% thread safe.
See moreDeclaration
Swift
public final class StrictRateLimitedDispatcher : RateLimitedDispatcherBase