-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Dispatcher implementations #1017
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| @@ -0,0 +1,31 @@ | |||
| #if !os(Linux) | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can instead add this to the exclude list in Package.swift for this target.
| /// A PromiseKit Dispatcher that allows no more than X simultaneous | ||
| /// executions at once. | ||
|
|
||
| class ConcurrencyLimitedDispatcher: Dispatcher { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, we can remove the when() that does this manually. I figure. Haven't analyzed them both.
|
This is really great, and truly shows the value of your changes, my sincere thanks and respect! |
* Add StrictRateLimitedDispatcher * Add ConcurrencyLimitedDispatcher * StrictRateLimitedDispatcher now schedules only on execution * Refactor rate limited dispatchers onto common base * Limiter dispatchers complete and tested * Add CoreDataDispatcher * Grooming, doc comments, NSLock -> DispatchQueue * Break Dispatcher implementation tests into separate classes to allow parallelism * Move time measurement outside of serialization for rate limit test * Update testing for Linux and slow Travis environments * Build all v7 branches
* Add StrictRateLimitedDispatcher * Add ConcurrencyLimitedDispatcher * StrictRateLimitedDispatcher now schedules only on execution * Refactor rate limited dispatchers onto common base * Limiter dispatchers complete and tested * Add CoreDataDispatcher * Grooming, doc comments, NSLock -> DispatchQueue * Break Dispatcher implementation tests into separate classes to allow parallelism * Move time measurement outside of serialization for rate limit test * Update testing for Linux and slow Travis environments * Build all v7 branches
* Add StrictRateLimitedDispatcher * Add ConcurrencyLimitedDispatcher * StrictRateLimitedDispatcher now schedules only on execution * Refactor rate limited dispatchers onto common base * Limiter dispatchers complete and tested * Add CoreDataDispatcher * Grooming, doc comments, NSLock -> DispatchQueue * Break Dispatcher implementation tests into separate classes to allow parallelism * Move time measurement outside of serialization for rate limit test * Update testing for Linux and slow Travis environments * Build all v7 branches
* Add StrictRateLimitedDispatcher * Add ConcurrencyLimitedDispatcher * StrictRateLimitedDispatcher now schedules only on execution * Refactor rate limited dispatchers onto common base * Limiter dispatchers complete and tested * Add CoreDataDispatcher * Grooming, doc comments, NSLock -> DispatchQueue * Break Dispatcher implementation tests into separate classes to allow parallelism * Move time measurement outside of serialization for rate limit test * Update testing for Linux and slow Travis environments * Build all v7 branches
* Add StrictRateLimitedDispatcher * Add ConcurrencyLimitedDispatcher * StrictRateLimitedDispatcher now schedules only on execution * Refactor rate limited dispatchers onto common base * Limiter dispatchers complete and tested * Add CoreDataDispatcher * Grooming, doc comments, NSLock -> DispatchQueue * Break Dispatcher implementation tests into separate classes to allow parallelism * Move time measurement outside of serialization for rate limit test * Update testing for Linux and slow Travis environments * Build all v7 branches
This is not for direct integration yet, just review.
I groomed the
Dispatcherobjects I ended up writing for another project and put them into a release-ready state. Take a look and see if you'd be interested in having these somewhere in the PromiseKit universe.They're simple but probably too peripheral to put in the core; however, they might make a reasonable add-on package. I suspect that these few applications would cover 90% of the things people might be interested in using
Dispatcherobjects for in the real world.Contents:
RateLimitedDispatcherimplements general dispatch rate limits with a token bucket (approximate) strategy.StrictRateLimitedDispatcheris an exact and optimal sliding window rate limiter, but requires O(n) space (n = # of events/interval)ConcurrencyLimitedDispatcherallows only n asynchronous closures to run at once.CoreDataDispatcherlets you dispatch onto threads associated withNSManagedObjectContexts.CoreDataDispatcheris trivial.ConcurrencyLimitedDispatcheris just a few lines of code as well, although the exact way to implement it might not be obvious to those without some GCD knowledge.The other two are a bit tricky to implement correctly and efficiently, so that's where I would locate the main value of releasing this stuff.