Module: AsyncIO
- Defined in:
- lib/async_io.rb,
lib/async_io/base.rb,
lib/async_io/worker.rb,
lib/async_io/rescuer.rb
Defined Under Namespace
Modules: Rescuer Classes: Base, Worker
Class Method Summary collapse
-
.async(task = proc {}, &payload) ⇒ Object
Creates async jobs, if a payload (i.e ruby block) is not given it passes an empty payload to woker.
- .async_creator ⇒ Object
- .async_creator=(new_async) ⇒ Object
- .async_with(task) ⇒ Object
Class Method Details
.async(task = proc {}, &payload) ⇒ Object
Creates async jobs, if a payload (i.e ruby block) is not given it passes an empty payload to woker. That allows us to do:
User.aget(1) User.aget(1) { |u| print u.id }
The response will be a worker that was created for this particular job.
NOTE: If you read PredictionIO::Worker you will see that it calls payload and passes job as its arguments. This is how it is available within a block later on. NOTE: You must pass a job ( i.e ruby block ).
29 30 31 |
# File 'lib/async_io.rb', line 29 def self.async(task = proc {}, &payload) async_creator.worker(payload, task) end |
.async_creator ⇒ Object
9 10 11 |
# File 'lib/async_io.rb', line 9 def self.async_creator @@async_creator ||= Base.new(5) end |
.async_creator=(new_async) ⇒ Object
5 6 7 |
# File 'lib/async_io.rb', line 5 def self.async_creator=(new_async) @@async_creator = new_async end |
.async_with(task) ⇒ Object
33 34 35 |
# File 'lib/async_io.rb', line 33 def self.async_with(task) async_creator.async_with(task) end |