Sha256: bca96a9fa916cf77ababf6eebc8c357216e9481bf8f7c8bfee54ff76d606dfad

Contents?: true

Size: 667 Bytes

Versions: 1

Compression:

Stored size: 667 Bytes

Contents

# frozen_string_literal: true

require_relative 'base'

module Legion
  module Extensions
    module Actors
      class Loop
        include Concurrent::Async
        include Legion::Extensions::Actors::Base

        def initialize
          @loop = true
          async.run
        rescue StandardError => e
          Legion::Logging.error e
          Legion::Logging.error e.backtrace
        end

        def run
          action while @loop
        end

        def action(**_opts)
          Legion::Logging.warn 'An extension is using the default action for a loop'
        end

        def cancel
          @loop = false
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
legionio-0.2.0 lib/legion/extensions/actors/loop.rb