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

Use concurrent-ruby's new Promises API #801

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions lib/sprockets/manifest.rb
Original file line number Diff line number Diff line change
Expand Up @@ -120,14 +120,14 @@ def find(*args, &block)
return to_enum(__method__, *args) unless block_given?

environment = self.environment.cached
promises = args.flatten.map do |path|
Concurrent::Promise.execute(executor: executor) do
futures = args.flatten.map do |path|
Concurrent::Promises.future_on(executor) do
environment.find_all_linked_assets(path).to_a
end
end

promises.each do |promise|
promise.value!.each(&block)
futures.each do |future|
future.value!.each(&block)
end

nil
Expand Down Expand Up @@ -188,15 +188,15 @@ def compile(*args)

filenames << asset.filename

promise = nil
future = nil
exporters_for_asset(asset) do |exporter|
next if exporter.skip?(logger)

if promise.nil?
promise = Concurrent::Promise.new(executor: executor) { exporter.call }
concurrent_exporters << promise.execute
if future.nil?
future = Concurrent::Promises.future_on(executor) { exporter.call }
concurrent_exporters << future
else
concurrent_exporters << promise.then { exporter.call }
concurrent_exporters << future.then { exporter.call }
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion sprockets.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Gem::Specification.new do |s|
s.executables = ["sprockets"]

s.add_dependency "rack", ">= 2.2.4", "< 4"
s.add_dependency "concurrent-ruby", "~> 1.0"
s.add_dependency "concurrent-ruby", "~> 1.1"

s.add_development_dependency "m", ">= 0"
s.add_development_dependency "babel-transpiler", "~> 0.6"
Expand Down
Loading