-
-
Save matthewd/bdc60893cc980e0afc01 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/lib/sprockets/manifest.rb b/lib/sprockets/manifest.rb | |
index e514ebb..9797575 100644 | |
--- a/lib/sprockets/manifest.rb | |
+++ b/lib/sprockets/manifest.rb | |
@@ -165,6 +165,8 @@ def compile(*args) | |
concurrent_compressors = [] | |
concurrent_writers = [] | |
+ pool = Concurrent::FixedThreadPool.new(5) | |
+ | |
find(*args) do |asset| | |
files[asset.digest_path] = { | |
'logical_path' => asset.logical_path, | |
@@ -189,7 +191,7 @@ def compile(*args) | |
logger.debug "Skipping #{target}, already exists" | |
else | |
logger.info "Writing #{target}" | |
- write_file = Concurrent::Future.execute { asset.write_to target } | |
+ write_file = Concurrent::Future.execute(executor: pool) { asset.write_to target } | |
concurrent_writers << write_file | |
end | |
filenames << asset.filename | |
@@ -202,15 +204,17 @@ def compile(*args) | |
logger.debug "Skipping #{target}.gz, already exists" | |
else | |
logger.info "Writing #{target}.gz" | |
- concurrent_compressors << Concurrent::Future.execute do | |
+ concurrent_compressors << Concurrent::Future.execute(executor: pool) do | |
write_file.wait! if write_file | |
gzip.compress(target) | |
end | |
end | |
end | |
+ | |
concurrent_writers.each(&:wait!) | |
concurrent_compressors.each(&:wait!) | |
+ pool.shutdown | |
save | |
filenames |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment