Sha256: 0f27610596d80be4c1f679d10a7d8cfed508c3f2c7d1bbeb4093c2d5fb510e62

Contents?: true

Size: 1.48 KB

Versions: 14

Compression:

Stored size: 1.48 KB

Contents

$:.unshift File.expand_path '../../lib', __FILE__

require 'bundler'
Bundler.require :default, :development, :test
require 'minitest/pride'
require 'minitest/autorun'
require 'angelo'
require 'angelo/minitest/helpers'
Celluloid.logger.level = ::Logger::ERROR
include Angelo::Minitest::Helpers

TEST_APP_ROOT = File.expand_path '../test_app_root', __FILE__

CK = 'ANGELO_CONCURRENCY' # concurrency key
DC = 5                    # default concurrency
CONCURRENCY = ENV.key?(CK) ? ENV[CK].to_i : DC

# https://gist.github.com/tkareine/739662
#
class CountDownLatch
  attr_reader :count

  def initialize(to)
    @count = to.to_i
    raise ArgumentError, "cannot count down from negative integer" unless @count >= 0
    @lock = Mutex.new
    @condition = ConditionVariable.new
  end

  def count_down
    @lock.synchronize do
      @count -= 1 if @count > 0
      @condition.broadcast if @count == 0
    end
  end

  def wait
    @lock.synchronize do
      @condition.wait(@lock) while @count > 0
    end
  end

end

module Cellper

  @@stop = false
  @@testers = {}

  def define_action sym, &block
    define_method sym, &block
  end

  def remove_action sym
    remove_method sym
  end

  def unstop!
    @@stop = false
  end

  def stop!
    @@stop = true
  end

  def stop?
    @@stop
  end

  def testers; @@testers; end

end

class Reactor
  include Celluloid::IO
  extend Cellper
end

$reactor = Reactor.new

class ActorPool
  include Celluloid
  extend Cellper
end

$pool = ActorPool.pool size: CONCURRENCY

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
angelo-0.1.22 test/spec_helper.rb
angelo-0.1.21 test/spec_helper.rb
angelo-0.1.19 test/spec_helper.rb
angelo-0.1.18 test/spec_helper.rb
angelo-0.1.17 test/spec_helper.rb
angelo-0.1.16 test/spec_helper.rb
angelo-0.1.15 test/spec_helper.rb
angelo-0.1.14 test/spec_helper.rb
angelo-0.1.13 test/spec_helper.rb
angelo-0.1.12 test/spec_helper.rb
angelo-0.1.11 test/spec_helper.rb
angelo-0.1.10 test/spec_helper.rb
angelo-0.1.9 test/spec_helper.rb
angelo-0.1.8 test/spec_helper.rb