engineyard-serverside 1.5.23.ruby19.16 → 1.5.24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (181) hide show
  1. data/lib/engineyard-serverside.rb +19 -17
  2. data/lib/engineyard-serverside/cli.rb +38 -30
  3. data/lib/engineyard-serverside/configuration.rb +4 -28
  4. data/lib/engineyard-serverside/deploy.rb +10 -7
  5. data/lib/engineyard-serverside/lockfile_parser.rb +2 -2
  6. data/lib/engineyard-serverside/logged_output.rb +2 -0
  7. data/lib/engineyard-serverside/server.rb +2 -27
  8. data/lib/engineyard-serverside/task.rb +14 -10
  9. data/lib/engineyard-serverside/version.rb +1 -1
  10. data/lib/vendor/dataflow/HISTORY +52 -0
  11. data/lib/vendor/dataflow/LICENSE +19 -0
  12. data/lib/vendor/dataflow/README.textile +290 -0
  13. data/lib/vendor/dataflow/Rakefile +36 -0
  14. data/lib/vendor/dataflow/examples/barrier.rb +9 -0
  15. data/lib/vendor/dataflow/examples/data_driven.rb +17 -0
  16. data/lib/vendor/dataflow/examples/dataflow_http_gets.rb +13 -0
  17. data/lib/vendor/dataflow/examples/flow.rb +20 -0
  18. data/lib/vendor/dataflow/examples/future_http_gets.rb +12 -0
  19. data/lib/vendor/dataflow/examples/future_queue.rb +11 -0
  20. data/lib/vendor/dataflow/examples/instance_variables.rb +15 -0
  21. data/lib/vendor/dataflow/examples/laziness.rb +9 -0
  22. data/lib/vendor/dataflow/examples/local_variables.rb +11 -0
  23. data/lib/vendor/dataflow/examples/messages.rb +26 -0
  24. data/lib/vendor/dataflow/examples/port_http_gets.rb +13 -0
  25. data/lib/vendor/dataflow/examples/port_send.rb +10 -0
  26. data/lib/vendor/dataflow/examples/ring.rb +21 -0
  27. data/lib/vendor/dataflow/spec/actor_spec.rb +28 -0
  28. data/lib/vendor/dataflow/spec/anonymous_variables_spec.rb +21 -0
  29. data/lib/vendor/dataflow/spec/barrier_spec.rb +25 -0
  30. data/lib/vendor/dataflow/spec/by_need_spec.rb +55 -0
  31. data/lib/vendor/dataflow/spec/dataflow_spec.rb +151 -0
  32. data/lib/vendor/dataflow/spec/equality_spec.rb +40 -0
  33. data/lib/vendor/dataflow/spec/flow_spec.rb +25 -0
  34. data/lib/vendor/dataflow/spec/forker_spec.rb +28 -0
  35. data/lib/vendor/dataflow/spec/future_queue_spec.rb +31 -0
  36. data/lib/vendor/dataflow/spec/inspect_spec.rb +19 -0
  37. data/lib/vendor/dataflow/spec/need_later_spec.rb +12 -0
  38. data/lib/vendor/dataflow/spec/port_spec.rb +26 -0
  39. data/lib/vendor/dataflow/spec/spec.opts +1 -0
  40. data/lib/vendor/dataflow/spec/spec_helper.rb +10 -0
  41. data/lib/vendor/escape/Readme +21 -0
  42. data/lib/vendor/escape/doc_include/template/qualitysmith.rb +631 -0
  43. data/lib/vendor/json_pure/CHANGES +166 -0
  44. data/lib/vendor/json_pure/COPYING +58 -0
  45. data/lib/vendor/json_pure/GPL +340 -0
  46. data/lib/vendor/json_pure/README +358 -0
  47. data/lib/vendor/json_pure/Rakefile +292 -0
  48. data/lib/vendor/json_pure/TODO +1 -0
  49. data/lib/vendor/json_pure/VERSION +1 -0
  50. data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkComparison.log +52 -0
  51. data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt#generator_fast-autocorrelation.dat +1000 -0
  52. data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt#generator_fast.dat +1001 -0
  53. data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt#generator_pretty-autocorrelation.dat +900 -0
  54. data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt#generator_pretty.dat +901 -0
  55. data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt#generator_safe-autocorrelation.dat +1000 -0
  56. data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt#generator_safe.dat +1001 -0
  57. data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt.log +261 -0
  58. data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure#generator_fast-autocorrelation.dat +1000 -0
  59. data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure#generator_fast.dat +1001 -0
  60. data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure#generator_pretty-autocorrelation.dat +1000 -0
  61. data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure#generator_pretty.dat +1001 -0
  62. data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure#generator_safe-autocorrelation.dat +1000 -0
  63. data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure#generator_safe.dat +1001 -0
  64. data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure.log +262 -0
  65. data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkRails#generator-autocorrelation.dat +1000 -0
  66. data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkRails#generator.dat +1001 -0
  67. data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkRails.log +82 -0
  68. data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkComparison.log +34 -0
  69. data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkExt#parser-autocorrelation.dat +900 -0
  70. data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkExt#parser.dat +901 -0
  71. data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkExt.log +81 -0
  72. data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkPure#parser-autocorrelation.dat +1000 -0
  73. data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkPure#parser.dat +1001 -0
  74. data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkPure.log +82 -0
  75. data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkRails#parser-autocorrelation.dat +1000 -0
  76. data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkRails#parser.dat +1001 -0
  77. data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkRails.log +82 -0
  78. data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkYAML#parser-autocorrelation.dat +1000 -0
  79. data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkYAML#parser.dat +1001 -0
  80. data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkYAML.log +82 -0
  81. data/lib/vendor/json_pure/benchmarks/generator2_benchmark.rb +222 -0
  82. data/lib/vendor/json_pure/benchmarks/generator_benchmark.rb +224 -0
  83. data/lib/vendor/json_pure/benchmarks/ohai.json +1216 -0
  84. data/lib/vendor/json_pure/benchmarks/ohai.ruby +1 -0
  85. data/lib/vendor/json_pure/benchmarks/parser2_benchmark.rb +251 -0
  86. data/lib/vendor/json_pure/benchmarks/parser_benchmark.rb +259 -0
  87. data/lib/vendor/json_pure/bin/edit_json.rb +9 -0
  88. data/lib/vendor/json_pure/bin/prettify_json.rb +75 -0
  89. data/lib/vendor/json_pure/data/example.json +1 -0
  90. data/lib/vendor/json_pure/data/index.html +38 -0
  91. data/lib/vendor/json_pure/data/prototype.js +4184 -0
  92. data/lib/vendor/json_pure/ext/json/ext/generator/extconf.rb +16 -0
  93. data/lib/vendor/json_pure/ext/json/ext/generator/generator.c +1323 -0
  94. data/lib/vendor/json_pure/ext/json/ext/generator/generator.h +170 -0
  95. data/lib/vendor/json_pure/ext/json/ext/parser/extconf.rb +15 -0
  96. data/lib/vendor/json_pure/ext/json/ext/parser/parser.c +1935 -0
  97. data/lib/vendor/json_pure/ext/json/ext/parser/parser.h +71 -0
  98. data/lib/vendor/json_pure/ext/json/ext/parser/parser.rl +792 -0
  99. data/lib/vendor/json_pure/install.rb +26 -0
  100. data/lib/vendor/json_pure/tests/fixtures/fail1.json +1 -0
  101. data/lib/vendor/json_pure/tests/fixtures/fail10.json +1 -0
  102. data/lib/vendor/json_pure/tests/fixtures/fail11.json +1 -0
  103. data/lib/vendor/json_pure/tests/fixtures/fail12.json +1 -0
  104. data/lib/vendor/json_pure/tests/fixtures/fail13.json +1 -0
  105. data/lib/vendor/json_pure/tests/fixtures/fail14.json +1 -0
  106. data/lib/vendor/json_pure/tests/fixtures/fail18.json +1 -0
  107. data/lib/vendor/json_pure/tests/fixtures/fail19.json +1 -0
  108. data/lib/vendor/json_pure/tests/fixtures/fail2.json +1 -0
  109. data/lib/vendor/json_pure/tests/fixtures/fail20.json +1 -0
  110. data/lib/vendor/json_pure/tests/fixtures/fail21.json +1 -0
  111. data/lib/vendor/json_pure/tests/fixtures/fail22.json +1 -0
  112. data/lib/vendor/json_pure/tests/fixtures/fail23.json +1 -0
  113. data/lib/vendor/json_pure/tests/fixtures/fail24.json +1 -0
  114. data/lib/vendor/json_pure/tests/fixtures/fail25.json +1 -0
  115. data/lib/vendor/json_pure/tests/fixtures/fail27.json +2 -0
  116. data/lib/vendor/json_pure/tests/fixtures/fail28.json +2 -0
  117. data/lib/vendor/json_pure/tests/fixtures/fail3.json +1 -0
  118. data/lib/vendor/json_pure/tests/fixtures/fail4.json +1 -0
  119. data/lib/vendor/json_pure/tests/fixtures/fail5.json +1 -0
  120. data/lib/vendor/json_pure/tests/fixtures/fail6.json +1 -0
  121. data/lib/vendor/json_pure/tests/fixtures/fail7.json +1 -0
  122. data/lib/vendor/json_pure/tests/fixtures/fail8.json +1 -0
  123. data/lib/vendor/json_pure/tests/fixtures/fail9.json +1 -0
  124. data/lib/vendor/json_pure/tests/fixtures/pass1.json +56 -0
  125. data/lib/vendor/json_pure/tests/fixtures/pass15.json +1 -0
  126. data/lib/vendor/json_pure/tests/fixtures/pass16.json +1 -0
  127. data/lib/vendor/json_pure/tests/fixtures/pass17.json +1 -0
  128. data/lib/vendor/json_pure/tests/fixtures/pass2.json +1 -0
  129. data/lib/vendor/json_pure/tests/fixtures/pass26.json +1 -0
  130. data/lib/vendor/json_pure/tests/fixtures/pass3.json +6 -0
  131. data/lib/vendor/json_pure/tests/test_json.rb +361 -0
  132. data/lib/vendor/json_pure/tests/test_json_addition.rb +162 -0
  133. data/lib/vendor/json_pure/tests/test_json_encoding.rb +68 -0
  134. data/lib/vendor/json_pure/tests/test_json_fixtures.rb +34 -0
  135. data/lib/vendor/json_pure/tests/test_json_generate.rb +122 -0
  136. data/lib/vendor/json_pure/tests/test_json_rails.rb +144 -0
  137. data/lib/vendor/json_pure/tests/test_json_unicode.rb +76 -0
  138. data/lib/vendor/json_pure/tools/fuzz.rb +139 -0
  139. data/lib/vendor/json_pure/tools/server.rb +61 -0
  140. data/lib/vendor/open4/lib/open4.rb +51 -80
  141. data/lib/vendor/thor/CHANGELOG.rdoc +89 -0
  142. data/lib/vendor/thor/LICENSE +20 -0
  143. data/lib/vendor/thor/README.rdoc +297 -0
  144. data/lib/vendor/thor/Thorfile +69 -0
  145. data/lib/vendor/thor/bin/rake2thor +86 -0
  146. data/lib/vendor/thor/bin/thor +6 -0
  147. data/lib/vendor/thor/thor.gemspec +120 -0
  148. data/spec/basic_deploy_spec.rb +1 -1
  149. data/spec/bundler_deploy_spec.rb +1 -1
  150. data/spec/nodejs_deploy_spec.rb +5 -2
  151. data/spec/rails31_deploy_spec.rb +3 -3
  152. data/spec/services_deploy_spec.rb +1 -1
  153. data/spec/support/integration.rb +1 -2
  154. metadata +165 -44
  155. data/lib/engineyard-serverside/future.rb +0 -29
  156. data/lib/engineyard-serverside/futures/celluloid.rb +0 -25
  157. data/lib/engineyard-serverside/futures/dataflow.rb +0 -31
  158. data/lib/vendor/celluloid/lib/celluloid.rb +0 -261
  159. data/lib/vendor/celluloid/lib/celluloid/actor.rb +0 -242
  160. data/lib/vendor/celluloid/lib/celluloid/actor_pool.rb +0 -54
  161. data/lib/vendor/celluloid/lib/celluloid/actor_proxy.rb +0 -75
  162. data/lib/vendor/celluloid/lib/celluloid/application.rb +0 -78
  163. data/lib/vendor/celluloid/lib/celluloid/calls.rb +0 -94
  164. data/lib/vendor/celluloid/lib/celluloid/core_ext.rb +0 -14
  165. data/lib/vendor/celluloid/lib/celluloid/events.rb +0 -14
  166. data/lib/vendor/celluloid/lib/celluloid/fiber.rb +0 -33
  167. data/lib/vendor/celluloid/lib/celluloid/fsm.rb +0 -141
  168. data/lib/vendor/celluloid/lib/celluloid/future.rb +0 -60
  169. data/lib/vendor/celluloid/lib/celluloid/links.rb +0 -61
  170. data/lib/vendor/celluloid/lib/celluloid/logger.rb +0 -32
  171. data/lib/vendor/celluloid/lib/celluloid/mailbox.rb +0 -124
  172. data/lib/vendor/celluloid/lib/celluloid/receivers.rb +0 -66
  173. data/lib/vendor/celluloid/lib/celluloid/registry.rb +0 -33
  174. data/lib/vendor/celluloid/lib/celluloid/responses.rb +0 -26
  175. data/lib/vendor/celluloid/lib/celluloid/rspec.rb +0 -2
  176. data/lib/vendor/celluloid/lib/celluloid/signals.rb +0 -50
  177. data/lib/vendor/celluloid/lib/celluloid/supervisor.rb +0 -57
  178. data/lib/vendor/celluloid/lib/celluloid/task.rb +0 -73
  179. data/lib/vendor/celluloid/lib/celluloid/tcp_server.rb +0 -33
  180. data/lib/vendor/celluloid/lib/celluloid/timers.rb +0 -109
  181. data/lib/vendor/celluloid/lib/celluloid/version.rb +0 -4
@@ -1,60 +0,0 @@
1
- require 'thread'
2
-
3
- module Celluloid
4
- # Celluloid::Future objects allow methods and blocks to run in the
5
- # background, their values requested later
6
- class Future
7
- # Create a new Celluloid::Future object, allowing a block to be computed in
8
- # the background and its return value obtained later
9
- def initialize(*args, &block)
10
- @lock = Mutex.new
11
- @value_obtained = false
12
-
13
- @runner = Runner.new(*args, &block)
14
- @runner.run!
15
- end
16
-
17
- # Obtain the value for this Future
18
- def value
19
- @lock.synchronize do
20
- unless @value_obtained
21
- @value = @runner.value
22
- @runner.terminate
23
- @value_obtained = true
24
- end
25
-
26
- @value
27
- end
28
- end
29
- alias_method :call, :value
30
-
31
- # Inspect this Celluloid::Future
32
- alias_method :inspect, :to_s
33
-
34
- # Runner is an internal class which executes the given block/method
35
- class Runner
36
- include Celluloid
37
-
38
- def initialize(*args, &block)
39
- @args, @block = args, block
40
- @called = nil
41
- @error = nil
42
- end
43
-
44
- def run
45
- @value = @block.call(*@args)
46
- rescue Exception => error
47
- @error = error
48
- ensure
49
- @called = true
50
- signal :finished
51
- end
52
-
53
- def value
54
- wait :finished unless @called
55
- abort @error if @error
56
- @value
57
- end
58
- end
59
- end
60
- end
@@ -1,61 +0,0 @@
1
- require 'thread'
2
-
3
- module Celluloid
4
- # Thread safe storage of inter-actor links
5
- class Links
6
- include Enumerable
7
-
8
- def initialize
9
- @links = {}
10
- @lock = Mutex.new
11
- end
12
-
13
- # Add an actor to the current links
14
- def <<(actor)
15
- @lock.synchronize do
16
- @links[actor.mailbox.address] = actor
17
- end
18
- actor
19
- end
20
-
21
- # Do links include the given actor?
22
- def include?(actor)
23
- @lock.synchronize do
24
- @links.has_key? actor.mailbox.address
25
- end
26
- end
27
-
28
- # Remove an actor from the links
29
- def delete(actor)
30
- @lock.synchronize do
31
- @links.delete actor.mailbox.address
32
- end
33
- actor
34
- end
35
-
36
- # Iterate through all links
37
- def each
38
- @lock.synchronize do
39
- @links.each { |_, actor| yield(actor) }
40
- end
41
- end
42
-
43
- # Map across links
44
- def map
45
- result = []
46
- each { |actor| result << yield(actor) }
47
- result
48
- end
49
-
50
- # Send an event message to all actors
51
- def send_event(event)
52
- each { |actor| actor.mailbox.system_event event }
53
- end
54
-
55
- # Generate a string representation
56
- def inspect
57
- links = self.map(&:inspect).join(',')
58
- "#<#{self.class}[#{links}]>"
59
- end
60
- end
61
- end
@@ -1,32 +0,0 @@
1
- module Celluloid
2
- module Logger
3
- module_function
4
-
5
- # Send a debug message
6
- def debug(string)
7
- Celluloid.logger.debug(string) if Celluloid.logger
8
- end
9
-
10
- # Send a info message
11
- def info(string)
12
- Celluloid.logger.info(string) if Celluloid.logger
13
- end
14
-
15
- # Send a warning message
16
- def warn(string)
17
- Celluloid.logger.warn(string) if Celluloid.logger
18
- end
19
-
20
- # Send an error message
21
- def error(string)
22
- Celluloid.logger.error(string) if Celluloid.logger
23
- end
24
-
25
- # Handle a crash
26
- def crash(string, exception)
27
- string += "\n#{exception.class}: #{exception.to_s}\n"
28
- string << exception.backtrace.join("\n")
29
- error(string)
30
- end
31
- end
32
- end
@@ -1,124 +0,0 @@
1
- require 'thread'
2
-
3
- module Celluloid
4
- class MailboxError < StandardError; end # you can't message the dead
5
- class MailboxShutdown < StandardError; end # raised if the mailbox can no longer be used
6
-
7
- # Actors communicate with asynchronous messages. Messages are buffered in
8
- # Mailboxes until Actors can act upon them.
9
- class Mailbox
10
- include Enumerable
11
-
12
- # A unique address at which this mailbox can be found
13
- alias_method :address, :object_id
14
-
15
- def initialize
16
- @messages = []
17
- @lock = Mutex.new
18
- @dead = false
19
- @condition = ConditionVariable.new
20
- end
21
-
22
- # Add a message to the Mailbox
23
- def <<(message)
24
- @lock.synchronize do
25
- raise MailboxError, "dead recipient" if @dead
26
-
27
- @messages << message
28
- @condition.signal
29
- end
30
- nil
31
- end
32
-
33
- # Add a high-priority system event to the Mailbox
34
- def system_event(event)
35
- @lock.synchronize do
36
- unless @dead # Silently fail if messages are sent to dead actors
37
- @messages.unshift event
38
- @condition.signal
39
- end
40
- end
41
- nil
42
- end
43
-
44
- # Receive a message from the Mailbox
45
- def receive(timeout = nil, &block)
46
- message = nil
47
-
48
- @lock.synchronize do
49
- raise MailboxError, "attempted to receive from a dead mailbox" if @dead
50
-
51
- begin
52
- message = next_message(&block)
53
-
54
- unless message
55
- if timeout
56
- now = Time.now
57
- wait_until ||= now + timeout
58
- wait_interval = wait_until - now
59
- return if wait_interval < 0
60
- else
61
- wait_interval = nil
62
- end
63
-
64
- @condition.wait(@lock, wait_interval)
65
- end
66
- end until message
67
- end
68
-
69
- message
70
- end
71
-
72
- # Retrieve the next message in the mailbox
73
- def next_message
74
- message = nil
75
-
76
- if block_given?
77
- index = @messages.index do |msg|
78
- yield(msg) || msg.is_a?(SystemEvent)
79
- end
80
-
81
- message = @messages.slice!(index, 1).first if index
82
- else
83
- message = @messages.shift
84
- end
85
-
86
- raise message if message.is_a? SystemEvent
87
- message
88
- end
89
-
90
- # Shut down this mailbox and clean up its contents
91
- def shutdown
92
- messages = nil
93
-
94
- @lock.synchronize do
95
- messages = @messages
96
- @messages = []
97
- @dead = true
98
- end
99
-
100
- messages.each { |msg| msg.cleanup if msg.respond_to? :cleanup }
101
- true
102
- end
103
-
104
- # Is the mailbox alive?
105
- def alive?
106
- !@dead
107
- end
108
-
109
- # Cast to an array
110
- def to_a
111
- @lock.synchronize { @messages.dup }
112
- end
113
-
114
- # Iterate through the mailbox
115
- def each(&block)
116
- to_a.each(&block)
117
- end
118
-
119
- # Inspect the contents of the Mailbox
120
- def inspect
121
- "#<#{self.class}:#{object_id.to_s(16)} @messages=[#{map { |m| m.inspect }.join(', ')}]>"
122
- end
123
- end
124
- end
@@ -1,66 +0,0 @@
1
- require 'set'
2
-
3
- module Celluloid
4
- # Allow methods to directly interact with the actor protocol
5
- class Receivers
6
- def initialize
7
- @receivers = Set.new
8
- @timers = Timers.new
9
- end
10
-
11
- # Receive an asynchronous message
12
- def receive(timeout = nil, &block)
13
- receiver = Receiver.new block
14
-
15
- if timeout
16
- receiver.timer = @timers.add(timeout) do
17
- @receivers.delete receiver
18
- receiver.resume
19
- end
20
- end
21
-
22
- @receivers << receiver
23
- Task.suspend
24
- end
25
-
26
- # How long to wait until the next timer fires
27
- def wait_interval
28
- @timers.wait_interval
29
- end
30
-
31
- # Fire any pending timers
32
- def fire_timers
33
- @timers.fire
34
- end
35
-
36
- # Handle incoming messages
37
- def handle_message(message)
38
- receiver = @receivers.find { |r| r.match(message) }
39
- return unless receiver
40
-
41
- @receivers.delete receiver
42
- @timers.cancel receiver.timer if receiver.timer
43
- receiver.resume message
44
- end
45
- end
46
-
47
- # Methods blocking on a call to receive
48
- class Receiver
49
- attr_accessor :timer
50
-
51
- def initialize(block)
52
- @block = block
53
- @task = Task.current
54
- @timer = nil
55
- end
56
-
57
- # Match a message with this receiver's block
58
- def match(message)
59
- @block.call(message) if @block
60
- end
61
-
62
- def resume(message = nil)
63
- @task.resume message
64
- end
65
- end
66
- end
@@ -1,33 +0,0 @@
1
- require 'thread'
2
-
3
- module Celluloid
4
- # The Registry allows us to refer to specific actors by human-meaningful names
5
- module Registry
6
- @@registry = {}
7
- @@registry_lock = Mutex.new
8
-
9
- # Register an Actor
10
- def []=(name, actor)
11
- actor_singleton = class << actor; self; end
12
- unless actor_singleton.ancestors.include? ActorProxy
13
- raise TypeError, "not an actor"
14
- end
15
-
16
- @@registry_lock.synchronize do
17
- @@registry[name.to_sym] = actor
18
- end
19
- end
20
-
21
- # Retrieve an actor by name
22
- def [](name)
23
- @@registry_lock.synchronize do
24
- @@registry[name.to_sym]
25
- end
26
- end
27
-
28
- # List all registered actors by name
29
- def registered
30
- @@registry_lock.synchronize { @@registry.keys }
31
- end
32
- end
33
- end
@@ -1,26 +0,0 @@
1
- module Celluloid
2
- # Responses to calls
3
- class Response
4
- attr_reader :call_id, :value
5
-
6
- def initialize(call_id, value)
7
- @call_id, @value = call_id, value
8
- end
9
- end
10
-
11
- # Call completed successfully
12
- class SuccessResponse < Response; end
13
-
14
- # Call was aborted due to caller error
15
- class ErrorResponse < Response
16
- def value
17
- if super.is_a? AbortError
18
- # Aborts are caused by caller error, so ensure they capture the
19
- # caller's backtrace instead of the receiver's
20
- raise super.cause.class.new(super.cause.message)
21
- else
22
- raise super
23
- end
24
- end
25
- end
26
- end
@@ -1,2 +0,0 @@
1
- require File.expand_path('../../../spec/support/actor_examples', __FILE__)
2
- require File.expand_path('../../../spec/support/mailbox_examples', __FILE__)
@@ -1,50 +0,0 @@
1
- module Celluloid
2
- # Event signaling between methods of the same object
3
- class Signals
4
- attr_reader :waiting
5
-
6
- def initialize
7
- @waiting = {}
8
- end
9
-
10
- # Wait for the given signal and return the associated value
11
- def wait(signal)
12
- tasks = @waiting[signal]
13
-
14
- case tasks
15
- when Array
16
- tasks << Task.current
17
- when NilClass
18
- @waiting[signal] = Task.current
19
- else
20
- @waiting[signal] = [tasks, Task.current]
21
- end
22
-
23
- Task.suspend
24
- end
25
-
26
- # Send a signal to all method calls waiting for the given name
27
- # Returns true if any calls were signaled, or false otherwise
28
- def send(name, value = nil)
29
- tasks = @waiting.delete name
30
-
31
- case tasks
32
- when Array
33
- tasks.each { |task| run_task task, value }
34
- when NilClass
35
- Logger.debug("spurious signal: #{name}")
36
- else
37
- run_task tasks, value
38
- end
39
-
40
- value
41
- end
42
-
43
- # Run the given task, reporting errors that occur
44
- def run_task(task, value)
45
- task.resume(value)
46
- rescue => ex
47
- Celluloid::Logger.crash("signaling error", ex)
48
- end
49
- end
50
- end