Class: Legion::Extensions::Actors::Loop

Inherits:
Object
  • Object
show all
Includes:
Concurrent::Async, Base
Defined in:
lib/legion/extensions/actors/loop.rb

Instance Method Summary collapse

Methods included from Base

#args, #check_subtask?, #enabled?, #function, #generate_task?, #manual, #runner, #use_runner?

Methods included from Helpers::Lex

#default_settings, #function_desc, #function_example, #function_options, #function_set, included, #runner_desc

Methods included from Helpers::Logger

#handle_exception, #log

Methods included from Helpers::Core

#find_setting, #settings

Methods included from Helpers::Base

#actor_class, #actor_const, #actor_name, #calling_class, #calling_class_array, #from_json, #full_path, #lex_class, #lex_const, #lex_name, #normalize, #runner_class, #runner_const, #runner_name, #to_dotted_hash

Constructor Details

#initializeLoop

Returns a new instance of Loop.



10
11
12
13
14
15
16
# File 'lib/legion/extensions/actors/loop.rb', line 10

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

Instance Method Details

#action(**_opts) ⇒ Object



22
23
24
# File 'lib/legion/extensions/actors/loop.rb', line 22

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

#cancelObject



26
27
28
# File 'lib/legion/extensions/actors/loop.rb', line 26

def cancel
  @loop = false
end

#runObject



18
19
20
# File 'lib/legion/extensions/actors/loop.rb', line 18

def run
  action while @loop
end