Skip to content
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

Wishlist: Unique/Serial Task + threading executor #553

Closed
rmoriz opened this issue Jul 14, 2016 · 3 comments
Closed

Wishlist: Unique/Serial Task + threading executor #553

rmoriz opened this issue Jul 14, 2016 · 3 comments
Labels
enhancement Adding features, adding tests, improving documentation.

Comments

@rmoriz
Copy link

rmoriz commented Jul 14, 2016

I've a feature request: We're using SuckerPunch which recently moved to concurrent-ruby Task, Queue and Executor models.

What we're missing are task implementations that by design are either "unique" (only 1 can be scheduled) or "serial" (only one can be executed at a time). I'm aware of SerializedExecution which would solve the "serial" aspect, however this would imply having a dedicated executor per task or limit all other (parallel) tasks, too.

Given that you already provide a TimerTask and SchedulerTask, how about a SerialTask and UniqueTask that can be executed using an multi-threading executor?

Thanks!

@pitr-ch
Copy link
Member

pitr-ch commented Jul 20, 2016

Yeah this came up in the past, we need a way to throttle concurrency. Thanks for reaching to us. So far we did not discuss it much.

My vision is to have following API for Promises:

uniq = Throttle.new 1
no_more_than_3 = Throttle.new 3

# 30 promises chains with throttled parts
30.times.map do |i|
  root = Promises.future(i) do |i|
    # full concurrency
    i + 1
  end.throttled(uniq) do |f|
    # only one at the time is executed
    f.then { |i| puts :c1, i; i }
  end.then do |i|
    # full concurrency
    i - 1
  end.throttled(no_more_than_3) do |f|
    # only 3 at the time is executed
    f.then { |i| puts :c3, i; i }
  end
end.map(&:value)

@pitr-ch pitr-ch added this to the 2.0.0 milestone Jul 20, 2016
@pitr-ch pitr-ch added the enhancement Adding features, adding tests, improving documentation. label Jul 20, 2016
@jdantonio
Copy link
Member

@rmoriz Thank you for the suggestion! This is definitely a feature we should look into at some point. Right now @pitr-ch need to focus our efforts on a 2.0 release do I'm going to tag this paused. We'll revisit after releasing 2.0. We're always happy to consider PRs for new features to Edge, so if anyone in the community would like to take this on in the mean time we'd be happy to support them.

@pitr-ch
Copy link
Member

pitr-ch commented Apr 17, 2017

The Throttle is part of edge now.

@pitr-ch pitr-ch closed this as completed Apr 17, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Adding features, adding tests, improving documentation.
Projects
None yet
Development

No branches or pull requests

3 participants