Class: GraphQL::Execution::Lazy::LazyMethodMap::ConcurrentishMap Private
- Inherits:
-
Object
- Object
- GraphQL::Execution::Lazy::LazyMethodMap::ConcurrentishMap
- Extended by:
- Forwardable
- Defined in:
- lib/graphql/execution/lazy/lazy_method_map.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Mock the Concurrent::Map API
Instance Method Summary collapse
-
#[]=(key, value) ⇒ Object
private
-
#compute_if_absent(key) ⇒ Object
private
-
#initialize ⇒ ConcurrentishMap
constructor
private
A new instance of ConcurrentishMap.
-
#initialize_copy(other) ⇒ Object
private
Constructor Details
#initialize ⇒ ConcurrentishMap
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of ConcurrentishMap.
63 64 65 66 67 68 |
# File 'lib/graphql/execution/lazy/lazy_method_map.rb', line 63 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 |
Instance Method Details
#[]=(key, value) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
70 71 72 73 74 |
# File 'lib/graphql/execution/lazy/lazy_method_map.rb', line 70 def []=(key, value) @semaphore.synchronize { @storage[key] = value } end |
#compute_if_absent(key) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
76 77 78 79 80 |
# File 'lib/graphql/execution/lazy/lazy_method_map.rb', line 76 def compute_if_absent(key) @semaphore.synchronize { @storage.fetch(key) { @storage[key] = yield } } end |
#initialize_copy(other) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
82 83 84 85 |
# File 'lib/graphql/execution/lazy/lazy_method_map.rb', line 82 def initialize_copy(other) @semaphore = Mutex.new @storage = other.copy_storage end |