Class: Thread

Inherits:
Object
  • Object
show all
Defined in:
lib/thread.rb

Class Method Summary collapse

Class Method Details

.exclusive { ... } ⇒ Object

Wraps a block in Thread.critical, restoring the original value upon exit from the critical section, and returns the value of the block.

Yields:

Returns:

  • (Object)


24
25
26
27
28
29
30
31
32
# File 'lib/thread.rb', line 24

def Thread.exclusive
  _old = Thread.critical
  begin
    Thread.critical = true
    return yield
  ensure
    Thread.critical = _old
  end
end