Skip to content

Commit 575bde2

Browse files
committed
Clear Monitor in MonitorMixin#freeze
A frozen object cannot be synchronized, so the Monitor serves no purpose and would prevent the object from being made Ractor-shareable.
1 parent 2253a86 commit 575bde2

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

lib/monitor.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,14 @@ def new_cond
160160
return ConditionVariable.new(@mon_data)
161161
end
162162

163+
# Clear the monitor before freezing. A frozen object cannot be
164+
# synchronized, so the Monitor serves no purpose and would prevent
165+
# the object from being made Ractor-shareable.
166+
def freeze
167+
@mon_data = nil
168+
super
169+
end
170+
163171
private
164172

165173
# Use <tt>extend MonitorMixin</tt> or <tt>include MonitorMixin</tt> instead

0 commit comments

Comments
 (0)