Skip to content

Commit

Permalink
Use built-in finalizer protocol for IO-related objects.
Browse files Browse the repository at this point in the history
  • Loading branch information
brixen committed Mar 21, 2016
1 parent baff08a commit c12f503
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions core/io.rb
Expand Up @@ -190,7 +190,7 @@ def initialize(fd, stat, io)
# Sometimes a FileDescriptor class is replaced (see IO#reopen) so we need to be
# careful we don't finalize that descriptor. Probably need a way to cancel
# the finalization when we are transferring an FD from one instance to another.
ObjectSpace.define_finalizer(self, method(:finalizer))
ObjectSpace.define_finalizer(self)
end
end

Expand Down Expand Up @@ -563,7 +563,7 @@ def cancel_finalizer
ObjectSpace.undefine_finalizer(self)
end

def finalizer(obj_id)
def __finalize__
return if @descriptor.nil? || @descriptor == -1

fd = @descriptor
Expand Down

0 comments on commit c12f503

Please sign in to comment.