class Concurrent::SerializedExecution

def posts(posts)

Parameters:
  • posts (Array, Proc)>) -- array of triplets where
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