Method: Concurrent::ReadWriteLock#with_write_lock

Defined in:
lib/concurrent-ruby/concurrent/atomic/read_write_lock.rb

#with_write_lock { ... } ⇒ Object

Execute a block operation within a write lock.

Yields:

  • the task to be performed within the lock.

Returns:

  • (Object)

    the result of the block operation.

Raises:



94
95
96
97
98
99
100
101
102
# File 'lib/concurrent-ruby/concurrent/atomic/read_write_lock.rb', line 94

def with_write_lock
  raise ArgumentError.new('no block given') unless block_given?
  acquire_write_lock
  begin
    yield
  ensure
    release_write_lock
  end
end