class Shrine::Plugins::Parallelize::ThreadPool

  1. lib/shrine/plugins/parallelize.rb
Superclass: Object

Methods

Public Class

  1. new

Public Instance

  1. enqueue
  2. perform

Public Class methods

new (size)
[show source]
# File lib/shrine/plugins/parallelize.rb, line 51
def initialize(size)
  @size = size
  @tasks = Queue.new
end

Public Instance methods

enqueue (&task)
[show source]
# File lib/shrine/plugins/parallelize.rb, line 56
def enqueue(&task)
  @tasks.enq(task)
end
perform ()
[show source]
# File lib/shrine/plugins/parallelize.rb, line 60
def perform
  threads = @size.times.map { spawn_thread }
  threads.each(&:join)
end