jason-o-matic-deep_test 1.2.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +47 -0
- data/README.rdoc +228 -0
- data/Rakefile +211 -0
- data/bin/deep_test +15 -0
- data/lib/deep_test.rb +90 -0
- data/lib/deep_test/database/mysql_setup_listener.rb +113 -0
- data/lib/deep_test/database/setup_listener.rb +116 -0
- data/lib/deep_test/deadlock_detector.rb +7 -0
- data/lib/deep_test/distributed/dispatch_controller.rb +53 -0
- data/lib/deep_test/distributed/drb_client_connection_info.rb +15 -0
- data/lib/deep_test/distributed/filename_resolver.rb +40 -0
- data/lib/deep_test/distributed/master_test_server.rb +52 -0
- data/lib/deep_test/distributed/multi_test_server_proxy.rb +44 -0
- data/lib/deep_test/distributed/null_work_unit.rb +12 -0
- data/lib/deep_test/distributed/remote_worker_client.rb +54 -0
- data/lib/deep_test/distributed/remote_worker_server.rb +111 -0
- data/lib/deep_test/distributed/rsync.rb +37 -0
- data/lib/deep_test/distributed/show_status.rhtml +41 -0
- data/lib/deep_test/distributed/test_server.rb +79 -0
- data/lib/deep_test/distributed/test_server_status.rb +9 -0
- data/lib/deep_test/distributed/test_server_workers.rb +24 -0
- data/lib/deep_test/distributed/throughput_runner.rb +42 -0
- data/lib/deep_test/distributed/throughput_statistics.rb +26 -0
- data/lib/deep_test/distributed/throughput_worker_client.rb +19 -0
- data/lib/deep_test/extensions/drb_extension.rb +34 -0
- data/lib/deep_test/extensions/object_extension.rb +40 -0
- data/lib/deep_test/listener_list.rb +17 -0
- data/lib/deep_test/local_workers.rb +55 -0
- data/lib/deep_test/logger.rb +17 -0
- data/lib/deep_test/marshallable_exception_wrapper.rb +44 -0
- data/lib/deep_test/metrics/gatherer.rb +67 -0
- data/lib/deep_test/metrics/queue_lock_wait_time_measurement.rb +133 -0
- data/lib/deep_test/null_worker_listener.rb +65 -0
- data/lib/deep_test/option.rb +70 -0
- data/lib/deep_test/options.rb +112 -0
- data/lib/deep_test/process_orchestrator.rb +49 -0
- data/lib/deep_test/rake_tasks.rb +11 -0
- data/lib/deep_test/result_reader.rb +36 -0
- data/lib/deep_test/rspec_detector.rb +24 -0
- data/lib/deep_test/server.rb +75 -0
- data/lib/deep_test/spec.rb +12 -0
- data/lib/deep_test/spec/extensions/example_group_methods.rb +64 -0
- data/lib/deep_test/spec/extensions/example_methods.rb +46 -0
- data/lib/deep_test/spec/extensions/options.rb +43 -0
- data/lib/deep_test/spec/extensions/reporter.rb +29 -0
- data/lib/deep_test/spec/extensions/spec_task.rb +20 -0
- data/lib/deep_test/spec/runner.rb +57 -0
- data/lib/deep_test/spec/work_result.rb +33 -0
- data/lib/deep_test/spec/work_unit.rb +59 -0
- data/lib/deep_test/test.rb +10 -0
- data/lib/deep_test/test/extensions/error.rb +14 -0
- data/lib/deep_test/test/runner.rb +24 -0
- data/lib/deep_test/test/supervised_test_suite.rb +49 -0
- data/lib/deep_test/test/work_result.rb +34 -0
- data/lib/deep_test/test/work_unit.rb +40 -0
- data/lib/deep_test/test_task.rb +51 -0
- data/lib/deep_test/ui/console.rb +76 -0
- data/lib/deep_test/ui/null.rb +17 -0
- data/lib/deep_test/warlock.rb +134 -0
- data/lib/deep_test/worker.rb +57 -0
- data/script/internal/run_test_suite.rb +7 -0
- data/script/public/master_test_server.rb +24 -0
- data/script/public/test_server.rb +18 -0
- data/script/public/test_throughput.rb +29 -0
- data/test/deep_test/database/mysql_setup_listener_test.rb +14 -0
- data/test/deep_test/distributed/dispatch_controller_test.rb +209 -0
- data/test/deep_test/distributed/drb_client_connection_info_test.rb +42 -0
- data/test/deep_test/distributed/filename_resolver_test.rb +52 -0
- data/test/deep_test/distributed/master_test_server_test.rb +32 -0
- data/test/deep_test/distributed/multi_test_server_proxy_test.rb +96 -0
- data/test/deep_test/distributed/remote_worker_client_test.rb +180 -0
- data/test/deep_test/distributed/remote_worker_server_test.rb +107 -0
- data/test/deep_test/distributed/rsync_test.rb +67 -0
- data/test/deep_test/distributed/test_server_test.rb +94 -0
- data/test/deep_test/distributed/test_server_workers_test.rb +26 -0
- data/test/deep_test/distributed/throughput_runner_test.rb +68 -0
- data/test/deep_test/distributed/throughput_worker_client_test.rb +28 -0
- data/test/deep_test/extensions/object_extension_test.rb +37 -0
- data/test/deep_test/listener_list_test.rb +20 -0
- data/test/deep_test/local_workers_test.rb +22 -0
- data/test/deep_test/logger_test.rb +11 -0
- data/test/deep_test/marshallable_exception_wrapper_test.rb +44 -0
- data/test/deep_test/metrics/gatherer_test.rb +66 -0
- data/test/deep_test/process_orchestrator_test.rb +11 -0
- data/test/deep_test/result_reader_test.rb +128 -0
- data/test/deep_test/server_test.rb +58 -0
- data/test/deep_test/test/extensions/error_test.rb +40 -0
- data/test/deep_test/test/runner_test.rb +7 -0
- data/test/deep_test/test/supervised_test_suite_test.rb +79 -0
- data/test/deep_test/test/work_result_test.rb +81 -0
- data/test/deep_test/test/work_unit_test.rb +61 -0
- data/test/deep_test/test_task_test.rb +43 -0
- data/test/deep_test/ui/console_test.rb +9 -0
- data/test/deep_test/warlock_test.rb +38 -0
- data/test/deep_test/worker_test.rb +94 -0
- data/test/failing.rake +11 -0
- data/test/failing.rb +7 -0
- data/test/fake_deadlock_error.rb +12 -0
- data/test/simple_test_blackboard.rb +45 -0
- data/test/simple_test_blackboard_test.rb +33 -0
- data/test/test_factory.rb +74 -0
- data/test/test_helper.rb +15 -0
- data/test/test_task_test.rb +72 -0
- metadata +160 -0
@@ -0,0 +1,65 @@
|
|
1
|
+
module DeepTest
|
2
|
+
#
|
3
|
+
# Listener that implements no-ops for all callbacks that DeepTest supports.
|
4
|
+
#
|
5
|
+
class NullWorkerListener
|
6
|
+
#
|
7
|
+
# Before DeepTest synchronizes any code during a distributed run,
|
8
|
+
# before_sync is called. If DeepTest is not running distributed,
|
9
|
+
# before_sync is never called.
|
10
|
+
#
|
11
|
+
def before_sync
|
12
|
+
end
|
13
|
+
|
14
|
+
#
|
15
|
+
# Before DeepTest starts any workers, it instantiates a listener and
|
16
|
+
# invokes this method. No other callbacks are made to the listener
|
17
|
+
# instance receiving this message.
|
18
|
+
#
|
19
|
+
def before_starting_workers
|
20
|
+
end
|
21
|
+
|
22
|
+
def before_remote_load_files
|
23
|
+
end
|
24
|
+
|
25
|
+
#
|
26
|
+
# A separate listener instance is created in each worker process and
|
27
|
+
# notified that the worker is starting. The worker for the process is
|
28
|
+
# provided for the listener to use. If you are using 3 workers, this
|
29
|
+
# method is invoked 3 times on 3 distinct instances. These instances
|
30
|
+
# will also receive the starting_work and finished_work callbacks for
|
31
|
+
# the worker provided.
|
32
|
+
#
|
33
|
+
def starting(worker)
|
34
|
+
end
|
35
|
+
|
36
|
+
#
|
37
|
+
# Each time a worker takes a work unit, it calls this method before
|
38
|
+
# doing the work. In total, this method will be called as many times
|
39
|
+
# as there are work units. The listener instance that received the
|
40
|
+
# starting callback with the worker provided here is the same instance
|
41
|
+
# that receives this message.
|
42
|
+
#
|
43
|
+
# Because each work processes work units in a serial fashion, the
|
44
|
+
# listener will receive a finished_work message before another
|
45
|
+
# starting_work message.
|
46
|
+
#
|
47
|
+
def starting_work(worker, work_unit)
|
48
|
+
end
|
49
|
+
|
50
|
+
#
|
51
|
+
# Each time a worker finishes computing a result for a work unit,
|
52
|
+
# it calls this method before sending that result back to the server.
|
53
|
+
# In total, this method will be called as many times
|
54
|
+
# as there are work units. The listener instance that received the
|
55
|
+
# starting callback with the worker provided here is the same instance
|
56
|
+
# that receives this message.
|
57
|
+
#
|
58
|
+
# Because each work processes work units in a serial fashion, the
|
59
|
+
# listener will receive a starting_work message before another
|
60
|
+
# finished_work message.
|
61
|
+
#
|
62
|
+
def finished_work(worker, work_unit, result)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
module DeepTest
|
2
|
+
class Option
|
3
|
+
attr_reader :name, :default
|
4
|
+
|
5
|
+
def initialize(name, type, default)
|
6
|
+
@name, @type, @default = name, type, default
|
7
|
+
end
|
8
|
+
|
9
|
+
def from_command_line(command_line)
|
10
|
+
command_line =~ /--#{name} (\S+)(\s|$)/
|
11
|
+
@type.from_string($1) if $1
|
12
|
+
end
|
13
|
+
|
14
|
+
def to_command_line(value)
|
15
|
+
"--#{name} #{@type.to_string(value)}" if value && value != default
|
16
|
+
end
|
17
|
+
|
18
|
+
module Hash
|
19
|
+
def self.to_string(hash)
|
20
|
+
pairs = []
|
21
|
+
hash.each do |key, value|
|
22
|
+
value = value.gsub(/ /,'%20') if (::String === value)
|
23
|
+
pairs << "#{key}:#{value.inspect}"
|
24
|
+
end
|
25
|
+
pairs.join(",")
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.from_string(string)
|
29
|
+
hash = {}
|
30
|
+
string.split(/,/).each do |pair|
|
31
|
+
key, unevaled_value = pair.split(/:/)
|
32
|
+
value = eval(unevaled_value)
|
33
|
+
value = value.gsub(/%20/, " ") if ::String === value
|
34
|
+
hash[key.to_sym] = value
|
35
|
+
end
|
36
|
+
hash
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
module Integer
|
41
|
+
def self.to_string(i)
|
42
|
+
i.to_s
|
43
|
+
end
|
44
|
+
|
45
|
+
def self.from_string(s)
|
46
|
+
s.to_i
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
module String
|
51
|
+
def self.to_string(s)
|
52
|
+
s
|
53
|
+
end
|
54
|
+
|
55
|
+
def self.from_string(s)
|
56
|
+
s
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
module Array
|
61
|
+
def self.to_string(a)
|
62
|
+
a.join(File::PATH_SEPARATOR)
|
63
|
+
end
|
64
|
+
|
65
|
+
def self.from_string(a)
|
66
|
+
a.split(File::PATH_SEPARATOR)
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
@@ -0,0 +1,112 @@
|
|
1
|
+
module DeepTest
|
2
|
+
class Options
|
3
|
+
unless defined?(VALID_OPTIONS)
|
4
|
+
VALID_OPTIONS = [
|
5
|
+
Option.new(:distributed_server, Option::String, nil),
|
6
|
+
Option.new(:number_of_workers, Option::Integer, 2),
|
7
|
+
Option.new(:metrics_file, Option::String, nil),
|
8
|
+
Option.new(:pattern, Option::String, nil),
|
9
|
+
Option.new(:server_port, Option::Integer, 6969),
|
10
|
+
Option.new(:sync_options, Option::Hash, {}),
|
11
|
+
Option.new(:timeout_in_seconds, Option::Integer, 30),
|
12
|
+
Option.new(:ui, Option::String, "DeepTest::UI::Console"),
|
13
|
+
Option.new(:worker_listener, Option::String, "DeepTest::NullWorkerListener"),
|
14
|
+
Option.new(:libs, Option::Array, []),
|
15
|
+
Option.new(:requires, Option::Array, []),
|
16
|
+
]
|
17
|
+
end
|
18
|
+
|
19
|
+
attr_accessor *VALID_OPTIONS.map {|o| o.name}
|
20
|
+
|
21
|
+
def ui=(value)
|
22
|
+
@ui = value.to_s
|
23
|
+
end
|
24
|
+
|
25
|
+
def worker_listener=(value)
|
26
|
+
@worker_listener = value.to_s
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.from_command_line(command_line)
|
30
|
+
hash = {}
|
31
|
+
VALID_OPTIONS.each do |option|
|
32
|
+
hash[option.name] = option.from_command_line(command_line)
|
33
|
+
end
|
34
|
+
new(hash)
|
35
|
+
end
|
36
|
+
|
37
|
+
def initialize(hash)
|
38
|
+
@origin_hostname = Socket.gethostname
|
39
|
+
check_option_keys(hash)
|
40
|
+
VALID_OPTIONS.each do |option|
|
41
|
+
send("#{option.name}=", hash[option.name] || option.default)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def gathering_metrics?
|
46
|
+
!@metrics_file.nil?
|
47
|
+
end
|
48
|
+
|
49
|
+
def new_listener_list
|
50
|
+
listeners = worker_listener.split(',').map do |listener|
|
51
|
+
eval(listener).new
|
52
|
+
end
|
53
|
+
ListenerList.new(listeners)
|
54
|
+
end
|
55
|
+
|
56
|
+
def origin_hostname
|
57
|
+
(Socket.gethostname == @origin_hostname) ? 'localhost' : @origin_hostname
|
58
|
+
end
|
59
|
+
|
60
|
+
# Don't store UI instances in the options instance, which will
|
61
|
+
# need to be dumped over DRb. UI instances may not be dumpable
|
62
|
+
# and we don't want to have to start yet another DRb Server
|
63
|
+
#
|
64
|
+
UI_INSTANCES = {} unless defined?(UI_INSTANCES)
|
65
|
+
def ui_instance
|
66
|
+
UI_INSTANCES[self] ||= eval(ui).new(self)
|
67
|
+
end
|
68
|
+
|
69
|
+
def to_command_line
|
70
|
+
command_line = []
|
71
|
+
VALID_OPTIONS.each do |option|
|
72
|
+
value = send(option.name)
|
73
|
+
command_line << option.to_command_line(value)
|
74
|
+
end
|
75
|
+
command_line.compact.join(' ')
|
76
|
+
end
|
77
|
+
|
78
|
+
def mirror_path(base)
|
79
|
+
raise "No source directory specified in sync_options" unless sync_options[:source]
|
80
|
+
relative_mirror_path = origin_hostname + sync_options[:source].gsub('/','_')
|
81
|
+
"#{base}/#{relative_mirror_path}"
|
82
|
+
end
|
83
|
+
|
84
|
+
def new_workers
|
85
|
+
if distributed_server.nil?
|
86
|
+
LocalWorkers.new self
|
87
|
+
else
|
88
|
+
begin
|
89
|
+
server = Distributed::TestServer.connect(self)
|
90
|
+
Distributed::RemoteWorkerClient.new(self, server, LocalWorkers.new(self))
|
91
|
+
rescue => e
|
92
|
+
ui_instance.distributed_failover_to_local("connect", e)
|
93
|
+
LocalWorkers.new self
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
def server
|
99
|
+
Server.remote_reference(origin_hostname, server_port)
|
100
|
+
end
|
101
|
+
|
102
|
+
protected
|
103
|
+
|
104
|
+
def check_option_keys(hash)
|
105
|
+
hash.keys.each do |key|
|
106
|
+
raise InvalidOptionError.new(key) unless VALID_OPTIONS.any? {|o| o.name == key.to_sym}
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
class InvalidOptionError < StandardError; end
|
111
|
+
end
|
112
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
module DeepTest
|
2
|
+
class ProcessOrchestrator
|
3
|
+
def self.run(options, workers, runner)
|
4
|
+
new(options, workers, runner).run
|
5
|
+
end
|
6
|
+
|
7
|
+
def initialize(options, workers, runner)
|
8
|
+
@options = options
|
9
|
+
@runner = runner
|
10
|
+
@workers = workers
|
11
|
+
end
|
12
|
+
|
13
|
+
def run(exit_when_done = true)
|
14
|
+
passed = false
|
15
|
+
|
16
|
+
begin
|
17
|
+
server = Server.start(@options)
|
18
|
+
@options.new_listener_list.before_starting_workers
|
19
|
+
@workers.start_all
|
20
|
+
begin
|
21
|
+
DeepTest.logger.debug "Loader Starting (#{$$})"
|
22
|
+
passed = @runner.process_work_units
|
23
|
+
ensure
|
24
|
+
shutdown(server)
|
25
|
+
end
|
26
|
+
ensure
|
27
|
+
DeepTest.logger.debug "ProcessOrchestrator: Stopping Server"
|
28
|
+
Server.stop
|
29
|
+
end
|
30
|
+
|
31
|
+
Kernel.exit(passed ? 0 : 1) if exit_when_done
|
32
|
+
end
|
33
|
+
|
34
|
+
def shutdown(server)
|
35
|
+
DeepTest.logger.debug "ProcessOrchestrator: Shutting Down"
|
36
|
+
server.done_with_work
|
37
|
+
|
38
|
+
first_exception = $!
|
39
|
+
begin
|
40
|
+
DeepTest.logger.debug "ProcessOrchestrator: Stopping Workers"
|
41
|
+
@workers.stop_all
|
42
|
+
rescue DRb::DRbConnError
|
43
|
+
# Workers must have already stopped
|
44
|
+
rescue Exception => e
|
45
|
+
raise first_exception || e
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
require "socket"
|
2
|
+
|
3
|
+
require File.dirname(__FILE__) + "/option"
|
4
|
+
require File.dirname(__FILE__) + "/options"
|
5
|
+
require File.dirname(__FILE__) + "/test_task"
|
6
|
+
require File.dirname(__FILE__) + "/rspec_detector"
|
7
|
+
|
8
|
+
DeepTest::RSpecDetector.if_rspec_available do
|
9
|
+
require 'spec/rake/spectask'
|
10
|
+
require File.dirname(__FILE__) + "/spec/extensions/spec_task"
|
11
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module DeepTest
|
2
|
+
class ResultReader
|
3
|
+
def initialize(blackboard)
|
4
|
+
@blackboard = blackboard
|
5
|
+
end
|
6
|
+
|
7
|
+
def read(original_work_units_by_id)
|
8
|
+
work_units_by_id = original_work_units_by_id.dup
|
9
|
+
errors = 0
|
10
|
+
|
11
|
+
begin
|
12
|
+
until errors == work_units_by_id.size
|
13
|
+
Thread.pass
|
14
|
+
result = @blackboard.take_result
|
15
|
+
next if result.nil?
|
16
|
+
|
17
|
+
if Worker::Error === result
|
18
|
+
puts result
|
19
|
+
errors += 1
|
20
|
+
else
|
21
|
+
if result.respond_to?(:output) && (output = result.output)
|
22
|
+
print output
|
23
|
+
end
|
24
|
+
|
25
|
+
work_unit = work_units_by_id.delete(result.identifier)
|
26
|
+
yield [work_unit, result]
|
27
|
+
end
|
28
|
+
end
|
29
|
+
rescue Server::ResultOverdueError
|
30
|
+
DeepTest.logger.error("Results are overdue from server, ending run")
|
31
|
+
end
|
32
|
+
|
33
|
+
work_units_by_id
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module DeepTest
|
2
|
+
class RSpecDetector
|
3
|
+
def self.if_rspec_available
|
4
|
+
require "rubygems"
|
5
|
+
# requiring 'spec' directly blows up unit-record
|
6
|
+
require "spec/version"
|
7
|
+
if defined?(::Spec)
|
8
|
+
if ::Spec::VERSION::MAJOR == 1 &&
|
9
|
+
::Spec::VERSION::MINOR == 1 &&
|
10
|
+
::Spec::VERSION::TINY == 8
|
11
|
+
yield
|
12
|
+
else
|
13
|
+
require 'spec/rake/spectask'
|
14
|
+
::Spec::Rake::SpecTask.class_eval do
|
15
|
+
def deep_test(options)
|
16
|
+
raise "* DeepTest RSpec support requires RSpec 1.1.8"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
rescue LoadError, Gem::LoadError
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,75 @@
|
|
1
|
+
module DeepTest
|
2
|
+
class Server
|
3
|
+
def self.start(options)
|
4
|
+
server = new(options)
|
5
|
+
DRb.start_service("druby://0.0.0.0:#{options.server_port}", server)
|
6
|
+
DeepTest.logger.info "Started DeepTest service at #{DRb.uri}"
|
7
|
+
server
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.stop
|
11
|
+
DRb.stop_service
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.remote_reference(address, port)
|
15
|
+
DRb.start_service
|
16
|
+
blackboard = DRbObject.new_with_uri("druby://#{address}:#{port}")
|
17
|
+
DeepTest.logger.debug "Connecting to DeepTest server at #{blackboard.__drburi}"
|
18
|
+
blackboard
|
19
|
+
end
|
20
|
+
|
21
|
+
def initialize(options)
|
22
|
+
@options = options
|
23
|
+
@work_queue = Queue.new
|
24
|
+
@result_queue = Queue.new
|
25
|
+
|
26
|
+
if Metrics::Gatherer.enabled?
|
27
|
+
require File.dirname(__FILE__) + "/metrics/queue_lock_wait_time_measurement"
|
28
|
+
@work_queue.extend Metrics::QueueLockWaitTimeMeasurement
|
29
|
+
@result_queue.extend Metrics::QueueLockWaitTimeMeasurement
|
30
|
+
Metrics::Gatherer.section("server queue lock wait times") do |s|
|
31
|
+
s.measurement("work queue total pop wait time", @work_queue.total_pop_time)
|
32
|
+
s.measurement("work queue total push wait time", @work_queue.total_push_time)
|
33
|
+
s.measurement("result queue total pop wait time", @result_queue.total_pop_time)
|
34
|
+
s.measurement("result queue total push wait time", @result_queue.total_push_time)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def done_with_work
|
40
|
+
@done_with_work = true
|
41
|
+
end
|
42
|
+
|
43
|
+
def take_result
|
44
|
+
Timeout.timeout(@options.timeout_in_seconds, ResultOverdueError) do
|
45
|
+
@result_queue.pop
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def take_work
|
50
|
+
raise NoWorkUnitsRemainingError if @done_with_work
|
51
|
+
|
52
|
+
@work_queue.pop(true)
|
53
|
+
rescue ThreadError => e
|
54
|
+
if e.message == "queue empty"
|
55
|
+
raise NoWorkUnitsAvailableError
|
56
|
+
else
|
57
|
+
raise
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
def write_result(result)
|
62
|
+
@result_queue.push result
|
63
|
+
nil
|
64
|
+
end
|
65
|
+
|
66
|
+
def write_work(work_unit)
|
67
|
+
@work_queue.push work_unit
|
68
|
+
nil
|
69
|
+
end
|
70
|
+
|
71
|
+
class NoWorkUnitsAvailableError < StandardError; end
|
72
|
+
class NoWorkUnitsRemainingError < StandardError; end
|
73
|
+
class ResultOverdueError < StandardError; end
|
74
|
+
end
|
75
|
+
end
|