Created
March 3, 2012 15:15
-
-
Save mlomnicki/1966580 to your computer and use it in GitHub Desktop.
DCell GC
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
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}" |
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
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