Sha256: 3ca103338a6121c4c086564820510e553c6cd0e8d6a9004b2e0951eede47521f

Contents?: true

Size: 1.03 KB

Versions: 2

Compression:

Stored size: 1.03 KB

Contents

# frozen_string_literal: true

export :Interrupt, :MoveOn, :Cancel, :Terminate

# Common exception class for interrupting fibers. These exceptions allow
# control of fibers. Interrupt 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. Interrupt exceptions can also
# references a cancel scope in order to allow correct bubbling of exceptions
# through nested cancel scopes.
class Interrupt < ::Exception
  attr_reader :scope, :value

  def initialize(scope = nil, value = nil)
    @scope = scope
    @value = value
  end
end

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

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

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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
polyphony-0.31 lib/polyphony/core/exceptions.rb
polyphony-0.30 lib/polyphony/core/exceptions.rb