Method: Concurrent::Map#compute_if_absent

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

#compute_if_absent(key) { ... } ⇒ 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 absent. This method is atomic.

Parameters:

  • key (Object)

Yields:

  • new value

Yield Returns:

  • (Object)

    new value

Returns:

  • (Object)

    new value or current value



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