Class: FSEvent::ProcessDevice
- Inherits:
-
AbstractDevice
- Object
- AbstractDevice
- FSEvent::ProcessDevice
- Defined in:
- lib/fsevent/processdevice.rb
Overview
processdevice.rb — run device on another process
Copyright © 2014 National Institute of Advanced Industrial Science and Technology (AIST)
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see <www.gnu.org/licenses/>.
Defined Under Namespace
Classes: Spawner
Instance Attribute Summary
Attributes inherited from AbstractDevice
Class Method Summary collapse
Instance Method Summary collapse
- #call_subprocess(method, *args) ⇒ Object
-
#finish ⇒ Object
private :call_subprocess.
- #framework=(framework) ⇒ Object
-
#initialize(device_name, io) ⇒ ProcessDevice
constructor
A new instance of ProcessDevice.
- #registered ⇒ Object
Methods inherited from AbstractDevice
#add_watch, #define_status, #del_watch, #inspect, #modify_status, #register_device, #run, #set_elapsed_time, #undefine_status, #unregister_device, #unregistered
Constructor Details
#initialize(device_name, io) ⇒ ProcessDevice
Returns a new instance of ProcessDevice.
58 59 60 61 |
# File 'lib/fsevent/processdevice.rb', line 58 def initialize(device_name, io) super device_name @io = io end |
Class Method Details
.spawner(defs) ⇒ Object
19 20 21 |
# File 'lib/fsevent/processdevice.rb', line 19 def self.spawner(defs) Spawner.new(defs) end |
Instance Method Details
#call_subprocess(method, *args) ⇒ Object
63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/fsevent/processdevice.rb', line 63 def call_subprocess(method, *args) Marshal.dump([:call_child, method, *args], @io) msgtype, *rest = Marshal.load(@io) while msgtype == :call_parent method, *args = rest ret = @framework.send(method, *args) Marshal.dump([:return_to_child, ret], @io) msgtype, *rest = Marshal.load(@io) end if msgtype != :return_to_parent raise FSEvent::FSEventError, "unexpected message type: #{msgtype.inspect}" end rest[0] end |
#finish ⇒ Object
private :call_subprocess
79 80 81 82 83 |
# File 'lib/fsevent/processdevice.rb', line 79 def finish @io.close_write @io.close nil end |
#framework=(framework) ⇒ Object
85 86 87 88 |
# File 'lib/fsevent/processdevice.rb', line 85 def framework=(framework) @framework = framework call_subprocess(:processdevice_framework_set) end |
#registered ⇒ Object
90 91 92 |
# File 'lib/fsevent/processdevice.rb', line 90 def registered call_subprocess(:processdevice_registered) end |