Sha256: dd435c6aa751459a640228cd84421130b2ab450a8c8cfc37e92c81a37029d870

Contents?: true

Size: 847 Bytes

Versions: 6

Compression:

Stored size: 847 Bytes

Contents

require_relative 'base'

module Legion
  module Extensions
    module Actors
      class Once
        include Legion::Extensions::Actors::Base

        def initialize
          return if disabled?

          if respond_to? :functions
            functions.each do
              function
              @task = Concurrent::ScheduledTask.execute(delay) do
                use_runner ? runner : manual
              end
            end
          else
            @task = Concurrent::ScheduledTask.execute(delay) do
              use_runner ? runner : manual
            end
          end
        rescue StandardError => e
          Legion::Logging.error e
        end

        def delay
          1.0
        end

        def cancel
          return if disabled?

          @task.cancel unless @task.cancelled?
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
legionio-0.4.2 lib/legion/extensions/actors/once.rb
legionio-0.4.1 lib/legion/extensions/actors/once.rb
legionio-0.4.0 lib/legion/extensions/actors/once.rb
legionio-0.3.2 lib/legion/extensions/actors/once.rb
legionio-0.3.1 lib/legion/extensions/actors/once.rb
legionio-0.3.0 lib/legion/extensions/actors/once.rb