5
# AutoPointer.new(pointer, method) => the passed Method will be invoked at GC time
6
# AutoPointer.new(pointer, proc) => the passed Proc will be invoked at GC time (SEE WARNING BELOW!)
7
# AutoPointer.new(pointer) { |p| ... } => the passed block will be invoked at GC time (SEE WARNING BELOW!)
8
# AutoPointer.new(pointer) => the pointer's release() class method will be invoked at GC time
10
# WARNING: passing a proc _may_ cause your pointer to never be GC'd, unless you're careful to avoid trapping a reference to the pointer in the proc. See the test specs for examples.
11
# WARNING: passing a block will cause your pointer to never be GC'd. This is bad.
13
# Please note that the safest, and therefore preferred, calling
14
# idiom is to pass a Method as the second parameter. Example usage:
17
# def self.release(pointer)
22
# p = AutoPointer.new(other_pointer, PointerHelper.method(:release))
24
# The above code will cause PointerHelper#release to be invoked at GC time.
26
# The last calling idiom (only one parameter) is generally only
27
# going to be useful if you subclass AutoPointer, and override
28
# release(), which by default does nothing.