Sha256: 04a4fc2faac49122d9b4211b406bb84d3b10a14c9b400adc68c197c5dbea6a19

Contents?: true

Size: 1.47 KB

Versions: 1

Compression:

Stored size: 1.47 KB

Contents

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

if RUBY_ENGINE == "ruby" && ENV['TRAVIS'] != 'true'
  require 'simplecov'
  SimpleCov.coverage_dir File.join('test', 'coverage')
  SimpleCov.start
  SimpleCov.command_name 'minitest'
end

$VERBOSE=nil # disable warnings turned on by default in rake 11.x

require 'bundler'
require 'celluloid/current'
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

$reactor = Reactor.new
$pool = Array.new(CONCURRENCY){|n| Actor.new}

def obj
  {'foo' => 'bar', 'bar' => 123.4567890123456, 'bat' => true}
end

def obj_s
  obj.keys.reduce({}){|h,k| h[k] = obj[k].to_s; h}
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
angelo-0.5.1 test/spec_helper.rb