Method: Concurrent::ReentrantReadWriteLock#with_write_lock

Defined in:
lib/concurrent-ruby/concurrent/atomic/reentrant_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:



145
146
147
148
149
150
151
152
153
# File 'lib/concurrent-ruby/concurrent/atomic/reentrant_read_write_lock.rb', line 145

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