lib/celluloid.rb in celluloid-0.12.1.pre vs lib/celluloid.rb in celluloid-0.12.1.pre2

- old
+ new

@@ -1,9 +1,10 @@ require 'logger' require 'thread' require 'timeout' require 'set' +require 'facter' module Celluloid extend self # expose all instance methods as singleton methods # How long actors have to terminate @@ -31,15 +32,22 @@ UUID.generate end # Obtain the number of CPUs in the system def cores - CPUCounter.cores + core_count = Facter.fact(:processorcount).value + Integer(core_count) end alias_method :cpus, :cores alias_method :ncpus, :cores + # Perform a stack dump of all actors to the given output object + def stack_dump(output = STDERR) + Celluloid::StackDumper.dump(output) + end + alias_method :dump, :stack_dump + # Define an exception handler for actor crashes def exception_handler(&block) Logger.exception_handler(&block) end @@ -71,11 +79,21 @@ end end end # Terminate all actors at exit - at_exit { shutdown } + at_exit do + if defined?(RUBY_ENGINE) && RUBY_ENGINE == "ruby" && RUBY_VERSION >= "1.9" + # workaround for MRI bug losing exit status in at_exit block + # http://bugs.ruby-lang.org/issues/5218 + exit_status = $!.status if $!.is_a?(SystemExit) + shutdown + exit exit_status if exit_status + else + shutdown + end + end # Class methods added to classes which include Celluloid module ClassMethods # Create a new actor def new(*args, &block) @@ -400,11 +418,10 @@ require 'celluloid/version' require 'celluloid/calls' require 'celluloid/core_ext' -require 'celluloid/cpu_counter' require 'celluloid/fiber' require 'celluloid/fsm' require 'celluloid/internal_pool' require 'celluloid/links' require 'celluloid/logger' @@ -412,10 +429,11 @@ require 'celluloid/method' require 'celluloid/receivers' require 'celluloid/registry' require 'celluloid/responses' require 'celluloid/signals' +require 'celluloid/stack_dumper' require 'celluloid/system_events' require 'celluloid/task' require 'celluloid/thread_handle' require 'celluloid/uuid' @@ -428,7 +446,8 @@ require 'celluloid/future' require 'celluloid/pool_manager' require 'celluloid/supervision_group' require 'celluloid/supervisor' require 'celluloid/notifications' +require 'celluloid/logging' require 'celluloid/boot'