Skip to content

Commit e0a7edd

Browse files
committed
Clarify reasons for separate methods to declare structure functions.
1 parent 9ae551b commit e0a7edd

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

lib/truffle/truffle/cext.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1427,16 +1427,17 @@ def rb_data_typed_object_wrap(ruby_class, data, data_type, mark, free, size)
14271427
object
14281428
end
14291429

1430+
# These data function are created in separate methods to ensure they
1431+
# will not accidentally capture the objects they operate on, which
1432+
# might prevent garbage collection.
14301433
def data_finalizer(free, data_holder)
1431-
# In a separate method to avoid capturing the object
14321434
raise unless free.respond_to?(:call)
14331435
proc {
14341436
Truffle.invoke_primitive(:interop_call_c_with_mutex, free, [data_holder.data]) unless data_holder.data.nil?
14351437
}
14361438
end
14371439

14381440
def data_marker(mark, data_holder)
1439-
# In a separate method to avoid capturing the object
14401441
raise unless mark.respond_to?(:call)
14411442
proc { |obj|
14421443
create_mark_list
@@ -1446,7 +1447,6 @@ def data_marker(mark, data_holder)
14461447
end
14471448

14481449
def data_sizer(sizer, data_holder)
1449-
# In a separate method to avoid capturing the object
14501450
raise unless sizer.respond_to?(:call)
14511451
proc {
14521452
Truffle.invoke_primitive(:interop_call_c_with_mutex, sizer, [data_holder.data])

0 commit comments

Comments
 (0)