Method: Concurrent::Map#compute_if_present

Defined in:
lib/concurrent-ruby/concurrent/map.rb

#compute_if_present(key) {|old_value| ... } ⇒ Object?

Note:

Atomic methods taking a block do not allow the self instance to be used within the block. Doing so will cause a deadlock.

Compute and store new value for key if the key is present. This method is atomic.

Parameters:

  • key (Object)

Yields:

  • new value

Yield Parameters:

  • old_value (Object)

Yield Returns:

  • (Object, nil)

    new value, when nil the key is removed

Returns:

  • (Object, nil)

    new value or nil



# File 'lib/concurrent-ruby/concurrent/map.rb', line 55