celluloid-pool-0.20.5/0000755000004100000410000000000012611241140014541 5ustar www-datawww-datacelluloid-pool-0.20.5/.env-ci0000644000004100000410000000020312611241140015716 0ustar www-datawww-dataCELLULOID_SPECS_LOG_STRATEGY=stderr CELLULOID_SPECS_LOG_LEVEL=3 CELLULOID_SPECS_LOG_FILE=log/ci.log CELLULOID_SPECS_LOG_SYNC=false celluloid-pool-0.20.5/Rakefile0000644000004100000410000000031512611241140016205 0ustar www-datawww-datarequire "bundler/gem_tasks" Dir["tasks/**/*.rake"].each { |task| load task } default_tasks = ["spec"] default_tasks << "rubocop" unless ENV["CI"] task default: default_tasks task ci: %w(spec benchmark) celluloid-pool-0.20.5/Gemfile0000644000004100000410000000012512611241140016032 0ustar www-datawww-datarequire File.expand_path("../culture/sync", __FILE__) Celluloid::Sync::Gemfile[self] celluloid-pool-0.20.5/.rspec0000644000004100000410000000011712611241140015655 0ustar www-datawww-data--color --format documentation --order random --warnings --require spec_helper celluloid-pool-0.20.5/LICENSE.txt0000644000004100000410000000206612611241140016370 0ustar www-datawww-dataThe MIT License (MIT) Copyright (c) 2015 Chris Heald Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. celluloid-pool-0.20.5/.travis.yml0000644000004100000410000000172612611241140016660 0ustar www-datawww-datascript: rake ci language: ruby rvm: - rbx-2 - jruby - 2.2.2 - 2.2.0 - 2.1.4 - 2.0.0 - 1.9.3 - ruby-head - jruby-head matrix: fast_finish: true allow_failures: - rvm: 1.9.3 - rvm: ruby-head - rvm: jruby-head - env: CELLULOID_BACKPORTED=true - env: CELLULOID_BACKPORTED=false CELLULOID_TASK_CLASS=Threaded - env: CELLULOID_BACKPORTED=true CELLULOID_TASK_CLASS=Threaded env: global: - NUMBER_OF_PROCESSORS=4 CELLULOID_CONFIG_FILE=.env-ci matrix: - CELLULOID_BACKPORTED=true - CELLULOID_BACKPORTED=false - CELLULOID_BACKPORTED=false CELLULOID_TASK_CLASS=Threaded - CELLULOID_BACKPORTED=true CELLULOID_TASK_CLASS=Threaded notifications: irc: "irc.freenode.org#celluloid" before_install: # Only use 1 job until Travis fixes the rbx --jobs issue. - if [ "$TRAVIS_RUBY_VERSION" == "rbx-2" ] ; then export BUNDLE_JOBS=1 ; else export BUNDLE_JOBS=4; fi sudo: false install: bundle install --without=development celluloid-pool-0.20.5/lib/0000755000004100000410000000000012611241140015307 5ustar www-datawww-datacelluloid-pool-0.20.5/lib/celluloid/0000755000004100000410000000000012611241140017263 5ustar www-datawww-datacelluloid-pool-0.20.5/lib/celluloid/supervision/0000755000004100000410000000000012611241140021651 5ustar www-datawww-datacelluloid-pool-0.20.5/lib/celluloid/supervision/container/0000755000004100000410000000000012611241140023633 5ustar www-datawww-datacelluloid-pool-0.20.5/lib/celluloid/supervision/container/behavior/0000755000004100000410000000000012611241140025432 5ustar www-datawww-datacelluloid-pool-0.20.5/lib/celluloid/supervision/container/behavior/pool.rb0000644000004100000410000000373212611241140026735 0ustar www-datawww-datarequire "set" module Celluloid module ClassMethods extend Forwardable def_delegators :"Celluloid::Supervision::Container::Pool", :pooling_options # Create a new pool of workers. Accepts the following options: # # * size: how many workers to create. Default is worker per CPU core # * args: array of arguments to pass when creating a worker # def pool(config={}, &block) _ = Celluloid.supervise(pooling_options(config, block: block, actors: self)) _.actors.last end # Same as pool, but links to the pool manager def pool_link(klass, config={}, &block) Supervision::Container::Pool.new_link(pooling_options(config, block: block, actors: klass)) end end module Supervision class Container extend Forwardable def_delegators :"Celluloid::Supervision::Container::Pool", :pooling_options def pool(klass, config={}, &block) _ = supervise(pooling_options(config, block: block, actors: klass)) _.actors.last end class Instance attr_accessor :pool, :pool_size end class << self # Register a pool of actors to be launched on group startup def pool(klass, config, &block) blocks << lambda do |container| container.pool(klass, config, &block) end end end class Pool include Behavior class << self def pooling_options(config={}, mixins={}) combined = {type: Celluloid::Supervision::Container::Pool}.merge(config).merge(mixins) combined[:args] = [[:block, :actors, :size, :args].inject({}) { |e, p| e[p] = combined.delete(p) if combined[p]; e }] combined end end identifier! :size, :pool configuration do @supervisor = Container::Pool @method = "pool_link" @pool = true @pool_size = @configuration[:size] @configuration end end end end end celluloid-pool-0.20.5/lib/celluloid/supervision/container/pool.rb0000644000004100000410000001333212611241140025133 0ustar www-datawww-datamodule Celluloid module Supervision class Container # Manages a fixed-size pool of actors # Delegates work (i.e. methods) and supervises actors # Don't use this class directly. Instead use MyKlass.pool class Pool include Celluloid trap_exit :__crash_handler__ finalizer :__shutdown__ attr_reader :size, :actors def initialize(options={}) @idle = [] @busy = [] @klass = options[:actors] @actors = Set.new @mutex = Mutex.new @size = options[:size] || [Celluloid.cores || 2, 2].max @args = options[:args] ? Array(options[:args]) : [] # Do this last since it can suspend and/or crash @idle = @size.times.map { __spawn_actor__ } end def __shutdown__ return unless defined?(@actors) && @actors # TODO: these can be nil if initializer crashes terminators = @actors.map do |actor| begin actor.future(:terminate) rescue DeadActorError end end terminators.compact.each { |terminator| terminator.value rescue nil } end def _send_(method, *args, &block) actor = __provision_actor__ begin actor._send_ method, *args, &block rescue DeadActorError # if we get a dead actor out of the pool wait :respawn_complete actor = __provision_actor__ retry rescue ::Exception => ex abort ex ensure if actor.alive? @idle << actor @busy.delete actor # Broadcast that actor is done processing and # waiting idle signal :actor_idle end end end def name _send_ @mailbox, :name end def is_a?(klass) _send_ :is_a?, klass end def kind_of?(klass) _send_ :kind_of?, klass end def methods(include_ancestors = true) _send_ :methods, include_ancestors end def to_s _send_ :to_s end def inspect _send_ :inspect end def size=(new_size) new_size = [0, new_size].max if new_size > size delta = new_size - size delta.times { @idle << __spawn_actor__ } else (size - new_size).times do actor = __provision_actor__ unlink actor @busy.delete actor @actors.delete actor actor.terminate end end @size = new_size end def busy_size @mutex.synchronize { @busy.length } end def idle_size @mutex.synchronize { @idle.length } end def __idle?(actor) @mutex.synchronize { @idle.include? actor } end def __busy?(actor) @mutex.synchronize { @busy.include? actor } end def __busy @mutex.synchronize { @busy } end def __idle @mutex.synchronize { @idle } end def __state(actor) return :busy if __busy?(actor) return :idle if __idle?(actor) :missing end # Instantiate an actor, add it to the actor Set, and return it def __spawn_actor__ actor = @klass.new_link(*@args) @mutex.synchronize { @actors.add(actor) } @actors.add(actor) actor end # Provision a new actor ( take it out of idle, move it into busy, and avail it ) def __provision_actor__ Task.current.guard_warnings = true @mutex.synchronize do while @idle.empty? # Wait for responses from one of the busy actors response = exclusive { receive { |msg| msg.is_a?(Internals::Response) } } Thread.current[:celluloid_actor].handle_message(response) end actor = @idle.shift @busy << actor actor end end # Spawn a new worker for every crashed one def __crash_handler__(actor, reason) @busy.delete actor @idle.delete actor @actors.delete actor return unless reason @idle << __spawn_actor__ signal :respawn_complete end def respond_to?(meth, include_private = false) # NOTE: use method() here since this class # shouldn't be used directly, and method() is less # likely to be "reimplemented" inconsistently # with other Object.*method* methods. found = method(meth) if include_private found ? true : false else if found.is_a?(UnboundMethod) found.owner.public_instance_methods.include?(meth) || found.owner.protected_instance_methods.include?(meth) else found.receiver.public_methods.include?(meth) || found.receiver.protected_methods.include?(meth) end end rescue NameError false end def method_missing(method, *args, &block) if respond_to?(method) _send_ method, *args, &block else super end end # Since Pool allocates worker objects only just before calling them, # we can still help Celluloid::Call detect passing invalid parameters to # async methods by checking for those methods on the worker class def method(meth) super rescue NameError @klass.instance_method(meth.to_sym) end end end end end celluloid-pool-0.20.5/lib/celluloid/pool.rb0000644000004100000410000000026712611241140020566 0ustar www-datawww-datarequire "celluloid" unless defined? Celluloid require "celluloid/supervision" require "celluloid/supervision/container/pool" require "celluloid/supervision/container/behavior/pool" celluloid-pool-0.20.5/.rubocop.yml0000644000004100000410000000005712611241140017015 0ustar www-datawww-datainherit_from: - culture/rubocop/rubocop.yml celluloid-pool-0.20.5/metadata.yml0000644000004100000410000001751012611241140017050 0ustar www-datawww-data--- !ruby/object:Gem::Specification name: celluloid-pool version: !ruby/object:Gem::Version version: 0.20.5 platform: ruby authors: - Tony Arcieri - Tim Carey-Smith - Donovan Keme autorequire: bindir: bin cert_chain: [] date: 2015-09-30 00:00:00.000000000 Z dependencies: - !ruby/object:Gem::Dependency name: bundler version_requirements: !ruby/object:Gem::Requirement requirements: - - ">=" - !ruby/object:Gem::Version version: '0' type: :development prerelease: false requirement: !ruby/object:Gem::Requirement requirements: - - ">=" - !ruby/object:Gem::Version version: '0' - !ruby/object:Gem::Dependency name: nenv version_requirements: !ruby/object:Gem::Requirement requirements: - - ">=" - !ruby/object:Gem::Version version: '0' type: :development prerelease: false requirement: !ruby/object:Gem::Requirement requirements: - - ">=" - !ruby/object:Gem::Version version: '0' - !ruby/object:Gem::Dependency name: dotenv version_requirements: !ruby/object:Gem::Requirement requirements: - - ">=" - !ruby/object:Gem::Version version: '0' type: :development prerelease: false requirement: !ruby/object:Gem::Requirement requirements: - - ">=" - !ruby/object:Gem::Version version: '0' - !ruby/object:Gem::Dependency name: benchmark_suite version_requirements: !ruby/object:Gem::Requirement requirements: - - ">=" - !ruby/object:Gem::Version version: '0' type: :development prerelease: false requirement: !ruby/object:Gem::Requirement requirements: - - ">=" - !ruby/object:Gem::Version version: '0' - !ruby/object:Gem::Dependency name: rubocop version_requirements: !ruby/object:Gem::Requirement requirements: - - ">=" - !ruby/object:Gem::Version version: '0' type: :development prerelease: false requirement: !ruby/object:Gem::Requirement requirements: - - ">=" - !ruby/object:Gem::Version version: '0' - !ruby/object:Gem::Dependency name: transpec version_requirements: !ruby/object:Gem::Requirement requirements: - - ">=" - !ruby/object:Gem::Version version: '0' type: :development prerelease: false requirement: !ruby/object:Gem::Requirement requirements: - - ">=" - !ruby/object:Gem::Version version: '0' - !ruby/object:Gem::Dependency name: pry version_requirements: !ruby/object:Gem::Requirement requirements: - - ">=" - !ruby/object:Gem::Version version: '0' type: :development prerelease: false requirement: !ruby/object:Gem::Requirement requirements: - - ">=" - !ruby/object:Gem::Version version: '0' - !ruby/object:Gem::Dependency name: rake version_requirements: !ruby/object:Gem::Requirement requirements: - - ">=" - !ruby/object:Gem::Version version: '0' type: :development prerelease: false requirement: !ruby/object:Gem::Requirement requirements: - - ">=" - !ruby/object:Gem::Version version: '0' - !ruby/object:Gem::Dependency name: rspec version_requirements: !ruby/object:Gem::Requirement requirements: - - ">=" - !ruby/object:Gem::Version version: '0' type: :development prerelease: false requirement: !ruby/object:Gem::Requirement requirements: - - ">=" - !ruby/object:Gem::Version version: '0' - !ruby/object:Gem::Dependency name: guard-rspec version_requirements: !ruby/object:Gem::Requirement requirements: - - ">=" - !ruby/object:Gem::Version version: '0' type: :development prerelease: false requirement: !ruby/object:Gem::Requirement requirements: - - ">=" - !ruby/object:Gem::Version version: '0' - !ruby/object:Gem::Dependency name: rspec-retry version_requirements: !ruby/object:Gem::Requirement requirements: - - ">=" - !ruby/object:Gem::Version version: '0' type: :development prerelease: false requirement: !ruby/object:Gem::Requirement requirements: - - ">=" - !ruby/object:Gem::Version version: '0' - !ruby/object:Gem::Dependency name: coveralls version_requirements: !ruby/object:Gem::Requirement requirements: - - ">=" - !ruby/object:Gem::Version version: '0' type: :development prerelease: false requirement: !ruby/object:Gem::Requirement requirements: - - ">=" - !ruby/object:Gem::Version version: '0' - !ruby/object:Gem::Dependency name: celluloid version_requirements: !ruby/object:Gem::Requirement requirements: - - ">=" - !ruby/object:Gem::Version version: 0.17.2 type: :development prerelease: false requirement: !ruby/object:Gem::Requirement requirements: - - ">=" - !ruby/object:Gem::Version version: 0.17.2 - !ruby/object:Gem::Dependency name: celluloid-essentials version_requirements: !ruby/object:Gem::Requirement requirements: - - ">=" - !ruby/object:Gem::Version version: '0' type: :development prerelease: false requirement: !ruby/object:Gem::Requirement requirements: - - ">=" - !ruby/object:Gem::Version version: '0' - !ruby/object:Gem::Dependency name: celluloid-supervision version_requirements: !ruby/object:Gem::Requirement requirements: - - ">=" - !ruby/object:Gem::Version version: '0' type: :development prerelease: false requirement: !ruby/object:Gem::Requirement requirements: - - ">=" - !ruby/object:Gem::Version version: '0' - !ruby/object:Gem::Dependency name: celluloid-fsm version_requirements: !ruby/object:Gem::Requirement requirements: - - ">=" - !ruby/object:Gem::Version version: '0' type: :development prerelease: false requirement: !ruby/object:Gem::Requirement requirements: - - ">=" - !ruby/object:Gem::Version version: '0' - !ruby/object:Gem::Dependency name: celluloid-extras version_requirements: !ruby/object:Gem::Requirement requirements: - - ">=" - !ruby/object:Gem::Version version: '0' type: :development prerelease: false requirement: !ruby/object:Gem::Requirement requirements: - - ">=" - !ruby/object:Gem::Version version: '0' - !ruby/object:Gem::Dependency name: timers version_requirements: !ruby/object:Gem::Requirement requirements: - - ">=" - !ruby/object:Gem::Version version: 4.1.1 type: :runtime prerelease: false requirement: !ruby/object:Gem::Requirement requirements: - - ">=" - !ruby/object:Gem::Version version: 4.1.1 description: An implementation of an actor pool, based on the Celluloid concurrent object framework. email: - tony.arcieri@gmail.com - code@extremist.digital executables: [] extensions: [] extra_rdoc_files: [] files: - ".env-ci" - ".env-dev" - ".gitignore" - ".gitmodules" - ".rspec" - ".rubocop.yml" - ".travis.yml" - CHANGES.md - Gemfile - LICENSE.txt - README.md - Rakefile - celluloid-pool.gemspec - lib/celluloid/pool.rb - lib/celluloid/supervision/container/behavior/pool.rb - lib/celluloid/supervision/container/pool.rb - tasks/benchmarks.rake - tasks/rspec.rake - tasks/rubocop.rake homepage: http://github.com/celluloid/celluloid-pool licenses: - MIT metadata: {} post_install_message: rdoc_options: [] require_paths: - lib required_ruby_version: !ruby/object:Gem::Requirement requirements: - - ">=" - !ruby/object:Gem::Version version: '0' required_rubygems_version: !ruby/object:Gem::Requirement requirements: - - ">=" - !ruby/object:Gem::Version version: '0' requirements: [] rubyforge_project: rubygems_version: 2.4.8 signing_key: specification_version: 4 summary: An implementation of an actor pool, based on the Celluloid concurrent object framework. test_files: [] celluloid-pool-0.20.5/.gitignore0000644000004100000410000000004412611241140016527 0ustar www-datawww-datalog/* coverage/* Gemfile.lock pkg/* celluloid-pool-0.20.5/tasks/0000755000004100000410000000000012611241140015666 5ustar www-datawww-datacelluloid-pool-0.20.5/tasks/rubocop.rake0000644000004100000410000000011312611241140020176 0ustar www-datawww-dataunless ENV["CI"] require "rubocop/rake_task" RuboCop::RakeTask.new end celluloid-pool-0.20.5/tasks/benchmarks.rake0000644000004100000410000000071212611241140020647 0ustar www-datawww-datarequire "timeout" desc "Run Celluloid benchmarks" task :benchmark do begin Timeout.timeout(120) do glob = File.expand_path("../../benchmarks/*.rb", __FILE__) Dir[glob].each { |benchmark| load benchmark } end rescue Exception, Timeout::Error => ex puts "ERROR: Couldn't complete benchmark: #{ex.class}: #{ex}" puts " #{ex.backtrace.join("\n ")}" exit 1 unless ENV["CI"] # Hax for running benchmarks on Travis end end celluloid-pool-0.20.5/tasks/rspec.rake0000644000004100000410000000017512611241140017651 0ustar www-datawww-datarequire "rspec/core/rake_task" RSpec::Core::RakeTask.new RSpec::Core::RakeTask.new(:rcov) do |task| task.rcov = true end celluloid-pool-0.20.5/CHANGES.md0000644000004100000410000000103012611241140016125 0ustar www-datawww-data0.20.5 (2015-09-30) ----- * Resumed updating changelog. Not much as changed -- mostly keeping version sync with other gems. * Revamped test suite, using shared RSpec configuration layer provided by Celluloid itself. * Updated gem dependencies provided by Celluloid::Sync... extraneous gems removed, or marked as development dependencies. 0.8.5 (2015-04-06) ----- * Initial release of very old code *as gem* separate of Celluloid. * Implemented `:injections` into `SupervisionGroup::Member` to resolve previous attachment requirements. celluloid-pool-0.20.5/celluloid-pool.gemspec0000644000004100000410000000146712611241140021041 0ustar www-datawww-data# coding: utf-8 require File.expand_path("../culture/sync", __FILE__) Gem::Specification.new do |gem| gem.name = "celluloid-pool" gem.version = "0.20.5" gem.authors = ["Tony Arcieri", "Tim Carey-Smith", "Donovan Keme"] gem.email = ["tony.arcieri@gmail.com", "code@extremist.digital"] gem.summary = "An implementation of an actor pool, based on the Celluloid concurrent object framework." gem.description = "An implementation of an actor pool, based on the Celluloid concurrent object framework." gem.homepage = "http://github.com/celluloid/celluloid-pool" gem.license = "MIT" gem.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|examples|spec|features)/}) } gem.require_paths = ["lib"] Celluloid::Sync::Gemspec[gem] end celluloid-pool-0.20.5/.env-dev0000644000004100000410000000020412611241140016102 0ustar www-datawww-dataCELLULOID_SPECS_LOG_STRATEGY=single CELLULOID_SPECS_LOG_FILE=log/test.log CELLULOID_SPECS_LOG_LEVEL=0 CELLULOID_SPECS_LOG_SYNC=true celluloid-pool-0.20.5/README.md0000644000004100000410000000027212611241140016021 0ustar www-datawww-data## Actor pools for Celluloid. [![Gem Version](https://badge.fury.io/rb/celluloid-pool.svg)](http://badge.fury.io/rb/celluloid-pool) Documentation coming. > This gem is in prerelease. celluloid-pool-0.20.5/.gitmodules0000644000004100000410000000012512611241140016714 0ustar www-datawww-data[submodule "culture"] path = culture url = http://github.com/celluloid/culture.git