Skip to content

Instantly share code, notes, and snippets.

@mlomnicki
Created March 3, 2012 15:15
Show Gist options
  • Save mlomnicki/1966580 to your computer and use it in GitHub Desktop.
Save mlomnicki/1966580 to your computer and use it in GitHub Desktop.
DCell GC
require 'dcell'
DCell.start :id => "client-node", :addr => "tcp://127.0.0.1:2032"
blog = DCell::Global[:blog]
post = blog.new_post
sleep 3
post.title = "hello dcell"
blog.publish_post(post)
puts "Published posts #{blog.published_posts.inspect}"
puts "All posts #{blog.posts.inspect}"
equire 'celluloid'
require 'dcell'
DCell.start
GC.stress = true if ENV['KILLME']
class Post
include Celluloid
attr_accessor :title, :published
end
class Blog
include Celluloid
attr_reader :posts
def initialize
@posts = []
end
def new_post
Post.new
end
def publish_post(post)
puts "Publishing post : #{post.title}"
@posts << post
post.published = true
end
def published_posts
@posts.collect(&:published)
end
end
Blog.supervise_as :blog
actor = Celluloid::Actor[:blog]
DCell::Global[:blog] = actor
DCell.run
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment