class GraphQL::Execution::Lazy::LazyMethodMap::ConcurrentishMap
Mock the Concurrent::Map API
Public Class Methods
new()
click to toggle source
# File lib/graphql/execution/lazy/lazy_method_map.rb, line 59 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
[]=(key, value)
click to toggle source
# File lib/graphql/execution/lazy/lazy_method_map.rb, line 66 def []=(key, value) @semaphore.synchronize { @storage[key] = value } end
compute_if_absent(key) { || ... }
click to toggle source
# File lib/graphql/execution/lazy/lazy_method_map.rb, line 72 def compute_if_absent(key) @semaphore.synchronize { @storage.fetch(key) { @storage[key] = yield } } end
initialize_copy(other)
click to toggle source
# File lib/graphql/execution/lazy/lazy_method_map.rb, line 78 def initialize_copy(other) @semaphore = Mutex.new @storage = other.copy_storage end
Protected Instance Methods
copy_storage()
click to toggle source
# File lib/graphql/execution/lazy/lazy_method_map.rb, line 85 def copy_storage @semaphore.synchronize { @storage.dup } end