lib/dagger/default.rb in ruby-dagger-0.2.0 vs lib/dagger/default.rb in ruby-dagger-0.2.1
- old
+ new
@@ -62,10 +62,11 @@
#
# :call-seq:
# with_locked_key(key &->(locked_key)) => result
def with_locked_key(key)
raise %(deadlock detected: "#{key}") unless @locks.add?(key)
+
yield(key)
ensure
@locks.delete(key)
end
@@ -74,9 +75,10 @@
# :call-seq:
# cached_value(tree, key) => value || KeyError
def cached_value(tree, key)
result = process(key)
return result unless result.nil?
+
result = @fallback&.[](key)
ensure
tree[key] = result if cached? && !result.nil?
end