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

Class Method Details

.async(payload, &job) ⇒ 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
32
# File 'lib/async_io.rb', line 29

def self.async(payload, &job)
  payload = payload || ->(n) { n }
  async_creator.worker(payload, &job)
end

.async_creatorObject



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