Class: Concurrent::PerThreadExecutor

Inherits:
Object
  • Object
show all
Includes:
Executor
Defined in:
lib/concurrent/executor/per_thread_executor.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Executor

#can_overflow?

Class Method Details

.post(*args) ⇒ Object

Raises:

  • (ArgumentError)


6
7
8
9
10
11
12
13
# File 'lib/concurrent/executor/per_thread_executor.rb', line 6

def self.post(*args)
  raise ArgumentError.new('no block given') unless block_given?
  Thread.new(*args) do
    Thread.current.abort_on_exception = false
    yield(*args)
  end
  return true
end

Instance Method Details

#<<(task) ⇒ Object



19
20
21
22
# File 'lib/concurrent/executor/per_thread_executor.rb', line 19

def <<(task)
  PerThreadExecutor.post(&task)
  return self
end

#post(*args, &task) ⇒ Object



15
16
17
# File 'lib/concurrent/executor/per_thread_executor.rb', line 15

def post(*args, &task)
  return PerThreadExecutor.post(*args, &task)
end