Module: Workers

Defined in:
lib/workers.rb,
lib/workers/pool.rb,
lib/workers/task.rb,
lib/workers/event.rb,
lib/workers/timer.rb,
lib/workers/worker.rb,
lib/workers/helpers.rb,
lib/workers/version.rb,
lib/workers/log_proxy.rb,
lib/workers/scheduler.rb,
lib/workers/exceptions.rb,
lib/workers/task_group.rb,
lib/workers/periodic_timer.rb,
lib/workers/bucket_scheduler.rb

Defined Under Namespace

Modules: Helpers Classes: BucketScheduler, Event, FailedTaskError, InvalidStateError, JoinError, LogProxy, MaxTriesError, MissingCallbackError, PeriodicTimer, Pool, PoolSizeError, Scheduler, Task, TaskGroup, Timer, UnknownEventError, Worker, WorkersError

Constant Summary collapse

VERSION =
'0.6.1'

Class Method Summary collapse

Class Method Details

.lock(&block) ⇒ Object


52
53
54
# File 'lib/workers.rb', line 52

def self.lock(&block)
  (@lock ||= Monitor.new).synchronize { yield if block_given? }
end

.map(inputs, options = {}, &block) ⇒ Object


46
47
48
49
50
# File 'lib/workers.rb', line 46

def self.map(inputs, options = {}, &block)
  return Workers::TaskGroup.new.map(inputs, options) do |i|
    yield(i)
  end
end

.poolObject


20
21
22
23
24
# File 'lib/workers.rb', line 20

def self.pool
  lock do
    @pool ||= Workers::Pool.new
  end
end

.pool=(val) ⇒ Object


26
27
28
29
30
31
# File 'lib/workers.rb', line 26

def self.pool=(val)
  lock do
    @pool.dispose if @pool
    @pool = val
  end
end

.schedulerObject


33
34
35
36
37
# File 'lib/workers.rb', line 33

def self.scheduler
  lock do
    @scheduler ||= Workers::Scheduler.new
  end
end

.scheduler=(val) ⇒ Object


39
40
41
42
43
44
# File 'lib/workers.rb', line 39

def self.scheduler=(val)
  lock do
    @scheduler.dispose if @scheduler
    @scheduler = val
  end
end