Module: Procrastinate

Defined in:
lib/procrastinate.rb,
lib/procrastinate/implicit.rb

Defined Under Namespace

Modules: IPC, SpawnStrategy, Task, Utils Classes: ChildDeath, Lock, ProcessManager, Proxy, Runtime, Scheduler

Class Method Summary collapse

Class Method Details

.joinObject

call-seq:

Procrastinate.join

Waits for all currently scheduled tasks to complete. This is like calling #value on all result objects, except that nothing is returned.

Example:

proxy = Procrastinate.proxy("foo")
r     = proxy += "bar"
Procrastinate.join
r.ready? # => true


45
46
47
# File 'lib/procrastinate/implicit.rb', line 45

def join
  scheduler.join
end

.proxy(obj) ⇒ Object

call-seq:

Procrastinate.proxy(obj) => proxy

Creates a proxy that will execute methods called on obj in a child process.

Example:

proxy = Procrastinate.proxy("foo")
r     = proxy += "bar"
r.value   # => 'foobar'


27
28
29
# File 'lib/procrastinate/implicit.rb', line 27

def proxy(obj)
  scheduler.proxy(obj)
end

.schedulerObject

call-seq:

Procrastinate.scheduler => scheduler

Returns the scheduler instance. When using procrastinate/implicit, there is one global scheduler to your ruby process, this one.



11
12
13
# File 'lib/procrastinate/implicit.rb', line 11

def scheduler
  @scheduler ||= Scheduler.start
end

.shutdownObject

Internal method: You should not have to shutdown the scheduler manually since it consumes almost no resources when not active. This is mainly useful in tests to achieve isolation.



54
55
56
# File 'lib/procrastinate/implicit.rb', line 54

def shutdown
  scheduler.shutdown
end