workers 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Workers is a Ruby gem for performing work in background threads.
4
4
  Design goals include high performance, low latency, simple API, customizability, and multi-layered architecture.
5
- The main features include workers, timers, and actors.
5
+ It is used by [Tribe](https://github.com/chadrem/tribe "Tribe") to implement event-driven actors.
6
6
 
7
7
  ## Installation
8
8
 
@@ -72,7 +72,7 @@ The Worker class is designed to be customized through inheritence and its event
72
72
  pool.join
73
73
 
74
74
  Note that you can use custom workers without a pool.
75
- This effectively gives you direct access to a single event driven thread.
75
+ This effectively gives you direct access to a single event-driven thread.
76
76
 
77
77
  ## Timers
78
78
 
@@ -117,64 +117,6 @@ You can create additional or custom ones as necessary:
117
117
  # Shutdown the scheduler.
118
118
  scheduler.dispose
119
119
 
120
- ## Actors
121
-
122
- Actors are light weight concurrent objects that use asynchronous message passing to communicate with each other.
123
- They are event driven and use a worker pool in order to execute their event loop.
124
-
125
- # Create your custom actor class.
126
- class MyActor < Workers::Actor
127
- private
128
- def initialize(options = {})
129
- super
130
- end
131
-
132
- def process_event(event)
133
- case event.command
134
- when :my_custom
135
- my_custom_handler(event)
136
- end
137
- end
138
-
139
- def my_custom_handler(event)
140
- puts "Received a custom event (#{event.inspect})"
141
- end
142
-
143
- def exception_handler(e)
144
- puts concat_e("MyActor (#{identifier}) died.", e)
145
- end
146
-
147
- def shutdown_handler(event)
148
- puts "MyActor (#{identifier}) is shutting down. Put cleanup code here."
149
- end
150
- end
151
-
152
- # Create some named actors.
153
- 100.times do |i|
154
- MyActor.new(:name => "my_actor_#{i}")
155
- end
156
-
157
- # Send an event to each actors. Find each actor using the registry.
158
- 100.times do |i|
159
- actor = Workers.registry["my_actor_#{i}"]
160
- actor.enqueue(:my_custom, 'hello world')
161
- end
162
-
163
- # Shutdown the actors.
164
- 100.times do |i|
165
- actor = Workers.registry["my_actor_#{i}"]
166
- actor.enqueue(:shutdown)
167
- end
168
-
169
- ### Implementation notes
170
- Because actors use a shared worker pool, it is important that they don't block for long periods of time.
171
- If you need an actor that can block for long periods then you should give the actor a dedicated thread (:dedicated => true).
172
-
173
- ## Registries
174
-
175
- Registries hold references to named actors.
176
- In general you shouldn't have to create your own since there is a global one (Workers.registry).
177
-
178
120
  ## Options (defaults below):
179
121
 
180
122
  pool = Workers::Pool.new(
@@ -205,25 +147,8 @@ In general you shouldn't have to create your own since there is a global one (Wo
205
147
  :logger => nil, # Ruby logger instance.
206
148
  :pool => Workers::Pool.new # The workers pool used to execute timer callbacks.
207
149
  )
208
-
209
- actor = Workers::Actor.new(
210
- :logger => nil, # Ruby logger instance.
211
- :dedicated => false, # If true, the actor runs with a worker pool that has one thread.
212
- :pool => Workers.pool, # The workers pool used to execute events.
213
- :mailbox => Workers::Mailbox.new, # The mailbox used to receive events.
214
- :registry => Workers.registry, # The registry used to store a reference to the actor if it has a name.
215
- :name => nil # The name of the actor (must be unique in the registry).
216
- )
217
-
218
- actor = Workers::DedicatedActor.new(
219
- :logger => nil, # Ruby logger instance.
220
- :mailbox => Workers::Mailbox.new, # The mailbox used to receive events.
221
- :registry => Workers.registry, # The registry used to store a reference to the actor if it has a name.
222
- :name => nil # The name of the actor (must be unique in the registry).
223
- )
224
-
225
150
 
226
- ## TODO - not yet implemented features
151
+ ## TODO - missing features
227
152
 
228
153
  ### Tasks
229
154
 
@@ -3,7 +3,7 @@ module Workers
3
3
  attr_accessor :logger
4
4
 
5
5
  def initialize(logger)
6
- @logger = logger
6
+ @logger = logger.is_a?(Workers::LogProxy) ? logger.logger : logger
7
7
  end
8
8
 
9
9
  def debug(msg)
@@ -1,3 +1,3 @@
1
1
  module Workers
2
- VERSION = '0.0.6'
2
+ VERSION = '0.0.7'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: workers
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-01-20 00:00:00.000000000 Z
12
+ date: 2013-01-28 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: Simple Ruby workers for performing work in background threads.
15
15
  email: