Skip to content
This repository was archived by the owner on Mar 15, 2022. It is now read-only.

Commit fac0e48

Browse files
author
Brian Durand
committed
make finalizers more thread safe
1 parent 41788eb commit fac0e48

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

lib/references/weak_reference/pure_ruby.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,11 @@ class WeakReference < Reference
1414

1515
# Finalizer that cleans up weak references when an object is destroyed.
1616
@@object_finalizer = lambda do |object_id|
17-
reference_ids = @@object_id_references[object_id]
17+
reference_ids = @@object_id_references.delete(object_id)
1818
if reference_ids
1919
reference_ids.each do |reference_object_id|
2020
@@referenced_object_ids.delete(reference_object_id)
2121
end
22-
@@object_id_references.delete(object_id)
2322
end
2423
end
2524

0 commit comments

Comments
 (0)