Skip to content

Commit

Permalink
Merge pull request #702 from HoneyryderChuck/issue-695
Browse files Browse the repository at this point in the history
Fix race condition for multi-thread support
  • Loading branch information
soutaro authored Jul 12, 2021
2 parents 21c85fd + 4e67199 commit 4981f59
Showing 1 changed file with 2 additions and 18 deletions.
20 changes: 2 additions & 18 deletions lib/rbs/definition_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -774,26 +774,10 @@ def merge_method(type_name, methods, name, method, sub, implemented_in: :keep, k
end

def try_cache(type_name, cache:, key: type_name)
# @type var cc: Hash[untyped, Definition | false | nil]
# @type var cc: Hash[untyped, Definition | nil]
cc = _ = cache
cached = cc[key]

case cached
when Definition
cached
when false
raise
when nil
cc[key] = false
begin
cc[key] = yield
rescue => ex
cc.delete(key)
raise ex
end
else
raise
end
cc[key] ||= yield
end

def expand_alias(type_name)
Expand Down

0 comments on commit 4981f59

Please sign in to comment.