class GraphQL::Execution::Lazy::LazyMethodMap::ConcurrentishMap
Mock the Concurrent::Map API
Public Class Methods
Source
# File lib/graphql/execution/lazy/lazy_method_map.rb, line 76 def initialize @semaphore = Mutex.new # Access to this hash must always be managed by the mutex # since it may be modified at runtime @storage = {} end
Public Instance Methods
Source
# File lib/graphql/execution/lazy/lazy_method_map.rb, line 83 def []=(key, value) @semaphore.synchronize { @storage[key] = value } end
# File lib/graphql/execution/lazy/lazy_method_map.rb, line 89 def compute_if_absent(key) @semaphore.synchronize { @storage.fetch(key) { @storage[key] = yield } } end
Source
# File lib/graphql/execution/lazy/lazy_method_map.rb, line 95 def initialize_copy(other) @semaphore = Mutex.new @storage = other.copy_storage end