Created
February 21, 2015 19:00
-
-
Save niamster/9f8dc8fb510164fbbc9c to your computer and use it in GitHub Desktop.
Test if celluloid actor is properly GCed once terminated
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'celluloid' | |
require 'weakref' | |
class Test | |
begin | |
include Celluloid | |
finalizer :shutdown | |
rescue | |
end | |
def initialize | |
ObjectSpace.define_finalizer(self, self.class.finalize) | |
end | |
def self.finalize | |
proc { p "finilize" } | |
end | |
def shutdown | |
p "shutdown" | |
end | |
def terminate | |
p "stub if celluloid is not includeed" | |
end | |
end | |
test = Test.new | |
test.terminate | |
weak = WeakRef.new test | |
test = nil | |
loop do | |
GC.start(full_mark: true, immediate_sweep: true) | |
break unless weak.weakref_alive? | |
sleep 1 | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment