Class: Roby::ExecutionEngine::PollBlockDefinition Private

Inherits:
Object
  • Object
show all
Defined in:
lib/roby/execution_engine.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Internal structure used to store a poll block definition provided to #every or #add_propagation_handler

Constant Summary collapse

ON_ERROR =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

%i[raise ignore disable].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(description, handler, on_error: :raise, late: false, once: false) ⇒ PollBlockDefinition

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of PollBlockDefinition.



223
224
225
226
227
228
229
230
231
232
# File 'lib/roby/execution_engine.rb', line 223

def initialize(description, handler, on_error: :raise, late: false, once: false)
    unless PollBlockDefinition::ON_ERROR.include?(on_error.to_sym)
        raise ArgumentError, "invalid value '#{on_error} for the :on_error option. Accepted values are #{ON_ERROR.map(&:to_s).join(', ')}"
    end

    @description, @handler, @on_error, @late, @once =
        description, handler, on_error, late, once
    @disabled = false
    @disposed = false
end

Instance Attribute Details

#descriptionObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



213
214
215
# File 'lib/roby/execution_engine.rb', line 213

def description
  @description
end

#handlerObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



213
214
215
# File 'lib/roby/execution_engine.rb', line 213

def handler
  @handler
end

#on_errorObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



213
214
215
# File 'lib/roby/execution_engine.rb', line 213

def on_error
  @on_error
end

Instance Method Details

#call(engine, *args) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
# File 'lib/roby/execution_engine.rb', line 247

def call(engine, *args)
    handler.call(*args)
    true
rescue Exception => e
    case on_error
    when :raise
        engine.add_framework_error(e, description)
        false
    when :disable
        engine.warn "propagation handler #{description} disabled "\
                    "because of the following error"
        Roby.log_exception_with_backtrace(e, engine, :warn)
        false
    when :ignore
        engine.warn "ignored error from propagation handler #{description}"
        Roby.log_exception_with_backtrace(e, engine, :warn)
        true
    end
end

#disposeObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



242
243
244
245
# File 'lib/roby/execution_engine.rb', line 242

def dispose
    @disabled = true
    @disposed = true
end

#disposed?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


238
239
240
# File 'lib/roby/execution_engine.rb', line 238

def disposed?
    @disposed
end

#idObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



219
220
221
# File 'lib/roby/execution_engine.rb', line 219

def id
    handler.object_id
end

#to_sObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



234
235
236
# File 'lib/roby/execution_engine.rb', line 234

def to_s
    "#<PollBlockDefinition: #{description} #{handler} on_error:#{on_error}>"
end