Class: Orocos::Async::CORBA::TaskContext
- Inherits:
-
TaskContextBase
- Object
- ObjectBase
- TaskContextBase
- Orocos::Async::CORBA::TaskContext
- Defined in:
- lib/orocos/async/task_context.rb
Instance Attribute Summary
Attributes inherited from TaskContextBase
Attributes included from ObjectBase::Periodic::ClassMethods
Attributes inherited from ObjectBase
#emitting, #event_loop, #name, #options, #pending_adds
Instance Method Summary collapse
- #configure_delegation(options = Hash.new) ⇒ Object
-
#initialize(ior, options = Hash.new) ⇒ TaskContext
constructor
A TaskContext.
- #ior ⇒ Object
- #method_missing(m, *args) ⇒ Object
- #really_add_listener(listener) ⇒ Object
- #respond_to_missing?(method_name, include_private = false) ⇒ Boolean
Methods inherited from TaskContextBase
#attribute, #call_with_async, #clear_interface, #each_attribute, #each_port, #each_property, #name, #port, #property, #reachable!, #reachable?, #ruby_task_context?, #to_async, #to_proxy, to_ruby, #to_ruby, #unreachable!
Methods included from ObjectBase::Periodic
#default_period, #period, #period=
Methods inherited from ObjectBase
#add_listener, define_event, define_events, #disable_emitting, #event, event_names, #event_names, #invalidate_delegator!, #listener?, #listeners, #number_of_listeners, #on_event, #proxy_event, #reachable!, #reachable?, #remove_all_listeners, #remove_listener, #remove_proxy_event, #unreachable!, #valid_delegator?, valid_event?, #valid_event?, validate_event, #validate_event, #wait
Constructor Details
#initialize(options) ⇒ TaskContext #initialize(task, options) ⇒ TaskContext
A TaskContext
If not specified the default option settings are:
:event_loop => Async.event_loop
:raise => false
:watchdog => true
:period => 1.0
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/orocos/async/task_context.rb', line 28 def initialize(ior,=Hash.new) if ior.respond_to?(:ior) ior = ior.ior end ior, = if ior.is_a? Hash [nil,ior] else [ior,] end ior ||= if .has_key? :ior [:ior] elsif .has_key? :use [:use].ior end name = [:name] || ior super(name,.merge(:ior => ior)) @ior = ior.to_str end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(m, *args) ⇒ Object
94 95 96 97 98 99 100 101 102 |
# File 'lib/orocos/async/task_context.rb', line 94 def method_missing(m,*args) if respond_to_missing?(m) event_loop.sync(@delegator_obj,args) do |args| @delegator_obj.method(m).call(*args) end else super end end |
Instance Method Details
#configure_delegation(options = Hash.new) ⇒ Object
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/orocos/async/task_context.rb', line 71 def configure_delegation( = Hash.new) = Kernel. , :name=> nil, :ior => nil ior = [:ior] @ior,@name = if valid_delegator? [@delegator_obj.ior,@delegator_obj.name] elsif ior.respond_to?(:ior) [ior.ior, ior.name] else [ior, @name] end if !@ior raise ArgumentError, "no IOR or task has been given" end end |
#ior ⇒ Object
61 62 63 64 65 |
# File 'lib/orocos/async/task_context.rb', line 61 def ior @mutex.synchronize do @ior.dup if @ior end end |
#really_add_listener(listener) ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/orocos/async/task_context.rb', line 47 def really_add_listener(listener) super # call new listeners with the current value # to prevent different behaviors depending on # the calling order if listener.use_last_value? && listener.event == :state_change state = @mutex.synchronize do @delegator_obj.current_state if valid_delegator? end event_loop.once{listener.call state} if state end end |
#respond_to_missing?(method_name, include_private = false) ⇒ Boolean
90 91 92 |
# File 'lib/orocos/async/task_context.rb', line 90 def respond_to_missing?(method_name, include_private = false) (reachable? && @delegator_obj.respond_to?(method_name)) || super end |