Skip to content

An example integrating stand-alone cells inside a celluloid actor.

Notifications You must be signed in to change notification settings

francescoagati/cell-celluloid

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

cell-celluloid

An example for integrate stand-alone cells inside celluloid actor.

rvm use 1.9.3
bundle install
bundle exec ruby main.rb

require 'action_pack'
require 'cell/base'
require "cell/rails/helper_api"
require 'celluloid'


#define a cell that render an action get_time
class Render < ::Cell::Base

  include Cell::Rails::HelperAPI

  def get_time
    @time=Time.new.to_s
    render
  end

end

#assign path for templates
Render.append_view_path("./views")

# an actor that implements the message get_time
class Actor
  
  attr_accessor :render
  include Celluloid
  
  def initialize
    @render=Render.new
  end

  def get_time
    render.render_state(:get_time)
  end
end

#create a pool of 50 actors
pool = Actor.pool(size:50)

#we do 100 rendering of cell Render sending 100 message to Actor and get the results of future
list_time=(0..100).to_a.map { |n| pool.future(:get_time) }.map {|actor| actor.value }
p list_time


About

An example integrating stand-alone cells inside a celluloid actor.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages