module Procrastinate

Public Class Methods

join() click to toggle source

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

@return [void]

# File lib/procrastinate/implicit.rb, line 57
def join
  scheduler.join
end
proxy(obj) click to toggle source

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'

@param obj [Object] Ruby object that the calls need to be proxied to @return [Proxy] proxy object that will execute method calls in child

processes
# File lib/procrastinate/implicit.rb, line 26
def proxy(obj)
  scheduler.proxy(obj)
end
reset() click to toggle source

Resets the implicit scheduler. Please use this only in tests, not in production code.

# File lib/procrastinate/implicit.rb, line 76
def reset
  scheduler.shutdown
  @scheduler = nil
end
schedule(&block) click to toggle source

Schedules a block to be executed in its own thread. Returns the future that will return the blocks return value.

@example

r = Procrastinate.schedule { do_some_work }
r.value                                     # => the blocks return value

@param block [Proc] block that will be executed in a child process @return [Task::Result] a promise for the blocks return value

# File lib/procrastinate/implicit.rb, line 41
def schedule(&block)
  scheduler.schedule(&block)
end
scheduler() click to toggle source

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

@return [Scheduler] singleton scheduler for implicit scheduling.

# File lib/procrastinate/implicit.rb, line 10
def scheduler
  @scheduler ||= Scheduler.start
end
shutdown() click to toggle source

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.

@private

# File lib/procrastinate/implicit.rb, line 68
def shutdown
  scheduler.shutdown
end

Private Instance Methods

join() click to toggle source

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

@return [void]

# File lib/procrastinate/implicit.rb, line 57
def join
  scheduler.join
end
proxy(obj) click to toggle source

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'

@param obj [Object] Ruby object that the calls need to be proxied to @return [Proxy] proxy object that will execute method calls in child

processes
# File lib/procrastinate/implicit.rb, line 26
def proxy(obj)
  scheduler.proxy(obj)
end
reset() click to toggle source

Resets the implicit scheduler. Please use this only in tests, not in production code.

# File lib/procrastinate/implicit.rb, line 76
def reset
  scheduler.shutdown
  @scheduler = nil
end
schedule(&block) click to toggle source

Schedules a block to be executed in its own thread. Returns the future that will return the blocks return value.

@example

r = Procrastinate.schedule { do_some_work }
r.value                                     # => the blocks return value

@param block [Proc] block that will be executed in a child process @return [Task::Result] a promise for the blocks return value

# File lib/procrastinate/implicit.rb, line 41
def schedule(&block)
  scheduler.schedule(&block)
end
scheduler() click to toggle source

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

@return [Scheduler] singleton scheduler for implicit scheduling.

# File lib/procrastinate/implicit.rb, line 10
def scheduler
  @scheduler ||= Scheduler.start
end
shutdown() click to toggle source

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.

@private

# File lib/procrastinate/implicit.rb, line 68
def shutdown
  scheduler.shutdown
end