Sha256: 53a2469af8108319f451a940619cad35b9c092769d49392c17781102532d982c
Contents?: true
Size: 1.18 KB
Versions: 1
Compression:
Stored size: 1.18 KB
Contents
require 'spec_helper' describe "Celluloid.pool", actor_system: :global do class ExampleError < StandardError; end class MyWorker include Celluloid def process(queue = nil) if queue queue << :done else :done end end def crash raise ExampleError, "zomgcrash" end end subject { MyWorker.pool } it "processes work units synchronously" do subject.process.should be :done end it "processes work units asynchronously" do queue = Queue.new subject.async.process(queue) queue.pop.should be :done end it "handles crashes" do expect { subject.crash }.to raise_error(ExampleError) subject.process.should be :done end it "uses a fixed-sized number of threads" do subject # eagerly evaluate the pool to spawn it actors = Celluloid::Actor.all 100.times.map { subject.future(:process) }.map(&:value) new_actors = Celluloid::Actor.all - actors new_actors.should eq [] end it "terminates" do expect { subject.terminate }.to_not raise_exception end it "handles many requests" do futures = 10.times.map do subject.future.process end futures.map(&:value) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
celluloid-0.16.0.pre | spec/celluloid/pool_spec.rb |