celluloid 0.17.0 → 0.17.1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of celluloid might be problematic. Click here for more details.

Files changed (51) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGES.md +10 -2
  3. data/LICENSE.txt +1 -1
  4. data/README.md +26 -14
  5. data/culture/gems/dependencies.yml +8 -2
  6. data/examples/stack.rb +47 -0
  7. data/lib/celluloid.rb +9 -6
  8. data/lib/celluloid/actor.rb +7 -32
  9. data/lib/celluloid/actor/manager.rb +7 -0
  10. data/lib/celluloid/actor/system.rb +163 -0
  11. data/lib/celluloid/call/sync.rb +1 -1
  12. data/lib/celluloid/calls.rb +3 -3
  13. data/lib/celluloid/cell.rb +1 -1
  14. data/lib/celluloid/condition.rb +3 -4
  15. data/lib/celluloid/debug.rb +1 -0
  16. data/lib/celluloid/deprecate.rb +3 -0
  17. data/lib/celluloid/exceptions.rb +20 -15
  18. data/lib/celluloid/future.rb +40 -3
  19. data/lib/celluloid/group.rb +5 -9
  20. data/lib/celluloid/group/pool.rb +1 -1
  21. data/lib/celluloid/group/spawner.rb +1 -2
  22. data/lib/celluloid/mailbox.rb +2 -2
  23. data/lib/celluloid/managed.rb +3 -0
  24. data/lib/celluloid/notices.rb +1 -1
  25. data/lib/celluloid/proxies.rb +7 -8
  26. data/lib/celluloid/proxy/abstract.rb +16 -21
  27. data/lib/celluloid/proxy/actor.rb +33 -37
  28. data/lib/celluloid/proxy/async.rb +24 -29
  29. data/lib/celluloid/proxy/block.rb +20 -24
  30. data/lib/celluloid/proxy/cell.rb +58 -62
  31. data/lib/celluloid/proxy/future.rb +33 -37
  32. data/lib/celluloid/proxy/sync.rb +31 -35
  33. data/lib/celluloid/system_events.rb +53 -1
  34. data/lib/celluloid/task.rb +13 -21
  35. data/lib/celluloid/task/fibered.rb +1 -1
  36. data/lib/celluloid/task/threaded.rb +2 -2
  37. data/lib/celluloid/version.rb +1 -1
  38. data/spec/celluloid/{group → actor}/manager_spec.rb +0 -0
  39. data/spec/celluloid/{actor_system_spec.rb → actor/system_spec.rb} +4 -4
  40. data/spec/celluloid/block_spec.rb +64 -3
  41. data/spec/celluloid/condition_spec.rb +6 -0
  42. data/spec/celluloid/future_spec.rb +2 -2
  43. data/spec/deprecate/actor_system_spec.rb +1 -1
  44. data/spec/deprecate/future_spec.rb +2 -2
  45. data/spec/shared/actor_examples.rb +20 -4
  46. data/spec/shared/group_examples.rb +1 -1
  47. data/spec/shared/mailbox_examples.rb +1 -1
  48. data/spec/spec_helper.rb +3 -3
  49. metadata +110 -76
  50. data/lib/celluloid/actor_system.rb +0 -160
  51. data/lib/celluloid/group/manager.rb +0 -27
@@ -1,160 +0,0 @@
1
- module Celluloid
2
- extend Forwardable
3
- def_delegators :actor_system, :[], :[]=
4
-
5
- class ActorSystem
6
- extend Forwardable
7
- def_delegators :@registry, :[], :get, :[]=, :set, :delete
8
-
9
- ROOT_SERVICES = [
10
- {
11
- as: :notifications_fanout,
12
- type: Celluloid::Notifications::Fanout,
13
- },
14
- {
15
- as: :incident_reporter,
16
- type: Celluloid::IncidentReporter,
17
- args: [STDERR],
18
- },
19
- {
20
- as: :group_manager,
21
- type: Celluloid::Group::Manager,
22
- accessors: [:manager],
23
- },
24
- {
25
- as: :public_services,
26
- type: Celluloid::Supervision::Service::Public,
27
- accessors: [:services],
28
- supervise: [],
29
- },
30
- ]
31
-
32
- attr_reader :registry, :group
33
-
34
- module Error
35
- class Uninitialized < StandardError; end
36
- end
37
-
38
- # the root of the supervisor tree is established at supervision/root
39
-
40
- def root_services
41
- @tree
42
- end
43
-
44
- def root_configuration
45
- @root
46
- end
47
-
48
- def initialize
49
- @tree = nil
50
- @group = Celluloid.group_class.new
51
- @registry = Internals::Registry.new
52
- @root = ROOT_SERVICES
53
- end
54
-
55
- # Launch default services
56
- def start
57
- within do
58
- @root = Supervision::Service::Root.define
59
- @tree = root_configuration.deploy
60
- # de root_services[:group_manager].manage! @group
61
- end
62
- true
63
- end
64
-
65
- def within
66
- old = Thread.current[:celluloid_actor_system]
67
- Thread.current[:celluloid_actor_system] = self
68
- yield
69
- ensure
70
- Thread.current[:celluloid_actor_system] = old
71
- end
72
-
73
- def get_thread
74
- @group.get do
75
- Thread.current[:celluloid_actor_system] = self
76
- yield
77
- end
78
- end
79
-
80
- def stack_dump
81
- Internals::Stack::Dump.new(@group)
82
- end
83
-
84
- def stack_summary
85
- Internals::Stack::Summary.new(@group)
86
- end
87
-
88
- def registered
89
- @registry.names
90
- end
91
-
92
- def clear_registry
93
- @registry.clear
94
- end
95
-
96
- def running
97
- actors = []
98
- @group.each do |t|
99
- next unless t.role == :actor
100
- actor = t.actor
101
-
102
- # NOTE - these are in separate statements, since on JRuby t.actor may
103
- # become nil befor .behavior_proxy() is called
104
- next unless actor
105
- next unless actor.respond_to?(:behavior_proxy)
106
- proxy = actor.behavior_proxy
107
- actors << proxy
108
- end
109
- actors
110
- end
111
-
112
- def running?
113
- @group.active?
114
- end
115
-
116
- # Shut down all running actors
117
- def shutdown
118
- actors = running
119
- Timeout.timeout(shutdown_timeout) do
120
- Internals::Logger.debug "Terminating #{actors.size} #{(actors.size > 1) ? 'actors' : 'actor'}..." if actors.size > 0
121
-
122
- # Actors cannot self-terminate, you must do it for them
123
- actors.each do |actor|
124
- begin
125
- actor.terminate!
126
- rescue DeadActorError
127
- end
128
- end
129
-
130
- actors.each do |actor|
131
- begin
132
- Actor.join(actor)
133
- rescue DeadActorError
134
- end
135
- end
136
- end
137
- rescue Timeout::Error
138
- Internals::Logger.error("Couldn't cleanly terminate all actors in #{shutdown_timeout} seconds!")
139
- unless RUBY_PLATFORM == "java" || RUBY_ENGINE == "rbx"
140
- actors.each do |actor|
141
- begin
142
- Actor.kill(actor)
143
- rescue DeadActorError, MailboxDead
144
- end
145
- end
146
- end
147
- ensure
148
- @group.shutdown
149
- clear_registry
150
- end
151
-
152
- def assert_inactive
153
- @group.assert_inactive
154
- end
155
-
156
- def shutdown_timeout
157
- Celluloid.shutdown_timeout
158
- end
159
- end
160
- end
@@ -1,27 +0,0 @@
1
- module Celluloid
2
- class Group
3
- class Manager
4
- include Celluloid
5
-
6
- def manage!(group)
7
- @group = group
8
- every(1.26) { garbage_collector }
9
- end
10
-
11
- def garbage_collector
12
- @group.each do |t|
13
- puts "running Group::Manager garbage_collector"
14
- # case t[:celluloid_meta][:state]
15
- # when :finished
16
- # # puts "thread finished: #{t.inspect}"
17
- # else
18
- # # puts "thread state: #{t[:celluloid_meta]}"
19
- # end
20
- # # puts "thread: #{t[:celluloid_actor].name}"
21
- end
22
- rescue => ex
23
- puts "#{ex.backtrace.first}"
24
- end
25
- end
26
- end
27
- end