Top Level Namespace
Defined Under Namespace
Modules: CodeReviewLeaderboard
Instance Method Summary
collapse
Instance Method Details
#WaitAll {|barrier| ... } ⇒ Object
3
4
5
6
7
8
9
|
# File 'lib/async/wait_all.rb', line 3
def WaitAll(&block)
barrier = Async::Barrier.new
yield barrier
barrier.wait
end
|
#WaitAllThrottled(array, concurrency: 5, &block) ⇒ Object
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
# File 'lib/async/wait_all_throttled.rb', line 7
def WaitAllThrottled(array, concurrency: 5, &block)
result = []
WaitAll do |barrier|
semaphore = Async::Semaphore.new(concurrency, parent: barrier)
Async do
array.each do |item|
semaphore.async(parent: barrier) do
result << yield(item)
end
end
end
end
result.flatten
end
|