Skip to content

Instantly share code, notes, and snippets.

@ravicious
Created September 4, 2015 19:32
Show Gist options
  • Save ravicious/e41b4a4dbea613cc3919 to your computer and use it in GitHub Desktop.
Save ravicious/e41b4a4dbea613cc3919 to your computer and use it in GitHub Desktop.
threads = concurrency_level.times.map { |i|
-> {
Thread.new do
begin
customers[i].buy_products([{quantity: 1, product: product}])
rescue Orders::CreateOrderService::Invalid
fail_occurred = true
end
end
}
}.map(&:call)
# We don't even need threads variable now!
concurrency_level.times.map { |i|
-> {
Thread.new do
begin
customers[i].buy_products([{quantity: 1, product: product}])
rescue Orders::CreateOrderService::Invalid
fail_occurred = true
end
end
}
}.map(&:call).map(&:join)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment