class Elevate::ElevateOperation

Executes an Elevate task, firing callbacks along the way.

Attributes

exception[R]

Returns the exception that terminated this task, if any.

If the task has not finished, returns nil.

@return [Exception, nil]

exception that terminated the task

@api public

result[R]

Returns the result of the task block.

If the task has not finished, returns nil.

@return [Object, nil]

result of the task block

@api public

Public Instance Methods

cancel() click to toggle source

Cancels the currently running task.

@return [void]

@api public

Calls superclass method
# File lib/elevate/operation.rb, line 27
def cancel
  @coordinator.cancel

  super
end
initWithTarget(target, args: args, channel: channel) click to toggle source

Designated initializer.

@return [ElevateOperation]

newly initialized instance

@api private

# File lib/elevate/operation.rb, line 11
def initWithTarget(target, args: args, channel: channel)
  if init
    @coordinator = IOCoordinator.new
    @context = TaskContext.new(target, channel, args)
    @exception = nil
    @result = nil
  end

  self
end
main() click to toggle source

Runs the specified task.

@return [void]

@api private

# File lib/elevate/operation.rb, line 38
def main
  @coordinator.install

  begin
    unless @coordinator.cancelled?
      @result = @context.execute
    end

  rescue => e
    @exception = e
  end

  @coordinator.uninstall

  @context = nil
end
timeout() click to toggle source

Cancels any waiting operation with a TimeoutError, interrupting execution. This is not the same as cancel.

@return [void]

@api public

# File lib/elevate/operation.rb, line 81
def timeout
  @coordinator.cancel(TimeoutError)
end