Method: JSI::Util::Private::MemoMap#initialize
- Defined in:
- lib/jsi/util/private/memo_map.rb
#initialize(key_by: nil, &block) ⇒ MemoMap
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 MemoMap.
6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/jsi/util/private/memo_map.rb', line 6 def initialize(key_by: nil, &block) @key_by = key_by @block = block || raise(ArgumentError, "no block given") # each result has its own mutex to update its memoized value thread-safely @result_mutexes = {} # another mutex to thread-safely initialize each result mutex @result_mutexes_mutex = Mutex.new @results = {} end |