Sha256: 9b37186e92137e34a3f699d9d7ded0342d9a3e8637fca602b2ee303ee6fcadfb

Contents?: true

Size: 1.18 KB

Versions: 2

Compression:

Stored size: 1.18 KB

Contents

# frozen_string_literal: true

export :BaseException, :MoveOn, :Cancel, :Terminate, :Restart

# Common exception class for interrupting fibers. These exceptions allow
# control of fibers. BaseException exceptions can encapsulate a value and thus
# provide a way to interrupt long-running blocking operations while still
# passing a value back to the call site. BaseException exceptions can also
# references a cancel scope in order to allow correct bubbling of exceptions
# through nested cancel scopes.
class BaseException < ::Exception
  attr_reader :value

  def initialize(value = nil)
    @caller_backtrace = caller
    @value = value
  end

  def backtrace
    sanitize(@caller_backtrace)
  end
end

# MoveOn is used to interrupt a long-running blocking operation, while
# continuing the rest of the computation.
class MoveOn < BaseException; end

# Cancel is used to interrupt a long-running blocking operation, bubbling the
# exception up through cancel scopes and supervisors.
class Cancel < BaseException; end

# Terminate is used to interrupt a fiber once its parent fiber has terminated.
class Terminate < BaseException; end

# Restart is used to restart a fiber
class Restart < BaseException; end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
polyphony-0.36 lib/polyphony/core/exceptions.rb
polyphony-0.34 lib/polyphony/core/exceptions.rb