Method: Concurrent::SerializedExecution#posts
- Defined in:
- lib/concurrent-ruby/concurrent/executor/serialized_execution.rb
#posts(posts) ⇒ Object
As #post but allows to submit multiple tasks at once, it’s guaranteed that they will not be interleaved by other tasks.
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/concurrent-ruby/concurrent/executor/serialized_execution.rb', line 44 def posts(posts) # if can_overflow? # raise ArgumentError, 'SerializedExecution does not support thread-pools which can overflow' # end return nil if posts.empty? jobs = posts.map { |executor, args, task| Job.new executor, args, task } job_to_post = synchronize do if @being_executed @stash.push(*jobs) nil else @being_executed = true @stash.push(*jobs[1..-1]) jobs.first end end call_job job_to_post if job_to_post true end |