class FSEvent::ProcessDevice

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/>.

Public Class Methods

new(device_name, io) click to toggle source
Calls superclass method FSEvent::AbstractDevice::new
# File lib/fsevent/processdevice.rb, line 58
def initialize(device_name, io)
  super device_name
  @io = io
end
spawner(defs) click to toggle source
# File lib/fsevent/processdevice.rb, line 19
def self.spawner(defs)
  Spawner.new(defs)
end

Public Instance Methods

call_subprocess(method, *args) click to toggle source
# 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() click to toggle source

private :call_subprocess

# File lib/fsevent/processdevice.rb, line 79
def finish
  @io.close_write
  @io.close
  nil
end
framework=(framework) click to toggle source
# File lib/fsevent/processdevice.rb, line 85
def framework=(framework)
  @framework = framework
  call_subprocess(:processdevice_framework_set)
end
registered() click to toggle source
# File lib/fsevent/processdevice.rb, line 90
def registered
  call_subprocess(:processdevice_registered)
end