Class: Isomorfeus::Speednode::Runtime::VM

Inherits:
Object
  • Object
show all
Defined in:
lib/isomorfeus/speednode/runtime.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ VM

Returns a new instance of VM.



23
24
25
26
27
28
29
# File 'lib/isomorfeus/speednode/runtime.rb', line 23

def initialize(options)
  @mutex = Mutex.new
  @socket_path = nil
  @options = options
  @started = false
  @socket = nil
end

Class Method Details

.exit_node(socket, socket_dir, socket_path, pid) ⇒ Object



39
40
41
42
43
44
45
# File 'lib/isomorfeus/speednode/runtime.rb', line 39

def self.exit_node(socket, socket_dir, socket_path, pid)
  VMCommand.new(socket, "exit", [0]).execute
  socket.close
  File.unlink(socket_path)
  Dir.rmdir(socket_dir)
  Process.kill('KILL', pid)
end

.finalize(socket, socket_dir, socket_path, pid) ⇒ Object



35
36
37
# File 'lib/isomorfeus/speednode/runtime.rb', line 35

def self.finalize(socket, socket_dir, socket_path, pid)
  proc { exit_node(socket, socket_dir, socket_path, pid) }
end

Instance Method Details

#delete_context(context) ⇒ Object



55
56
57
# File 'lib/isomorfeus/speednode/runtime.rb', line 55

def delete_context(context)
  command("deleteContext", context)
end

#exec(context, source) ⇒ Object



47
48
49
# File 'lib/isomorfeus/speednode/runtime.rb', line 47

def exec(context, source)
  command("exec", {'context' => context, 'source' => source})
end

#execp(context, source) ⇒ Object



51
52
53
# File 'lib/isomorfeus/speednode/runtime.rb', line 51

def execp(context, source)
  command("execp", {'context' => context, 'source' => source})
end

#startObject



59
60
61
62
63
# File 'lib/isomorfeus/speednode/runtime.rb', line 59

def start
  @mutex.synchronize do
    start_without_synchronization
  end
end

#started?Boolean

Returns:

  • (Boolean)


31
32
33
# File 'lib/isomorfeus/speednode/runtime.rb', line 31

def started?
  @started
end