Skip to content

Latest commit

 

History

History
19 lines (14 loc) · 848 Bytes

README.md

File metadata and controls

19 lines (14 loc) · 848 Bytes

MPRateLimiter Carthage compatible

A synchronous rate limiter for Swift.

  • The current thread waits for the closure's rate limited execution.
  • Public interface is thread safe.
  • Allows for rethrowing errors thrown by the rate limited executed closure.

If you don't want this behaviour where waiting is done synchronously, and instead need rate limiting of the sort where rate limited execution may be dispatched asynchronously in another call stack, you may want to try something like DORateLimit instead.

Usage examples

let limiter = RateLimiter()

// Executes at the maximum rate of 0.1s since the previously executed closure with matching key "foo"
limiter.execute(key:"foo", rateLimit:0.1) {
  print("bar")
}