Class: ExecJS::FastNode::ExternalPipedRuntime::VM

Inherits:
Object
  • Object
show all
Defined in:
lib/execjs/fastnode/external_piped_runtime.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ VM

Returns a new instance of VM.



14
15
16
17
18
# File 'lib/execjs/fastnode/external_piped_runtime.rb', line 14

def initialize(options)
  @mutex = Mutex.new
  @stdin = @stdout = @wait_thr = nil
  @options = options
end

Instance Attribute Details

#stdinObject (readonly)

Returns the value of attribute stdin.



12
13
14
# File 'lib/execjs/fastnode/external_piped_runtime.rb', line 12

def stdin
  @stdin
end

#stdoutObject (readonly)

Returns the value of attribute stdout.



12
13
14
# File 'lib/execjs/fastnode/external_piped_runtime.rb', line 12

def stdout
  @stdout
end

Class Method Details

.finalize(stdin) ⇒ Object



24
25
26
# File 'lib/execjs/fastnode/external_piped_runtime.rb', line 24

def self.finalize(stdin)
  proc { stdin.puts('{"cmd": "exit", "arguments": [0]}') }
end

Instance Method Details

#delete_context(context) ⇒ Object



32
33
34
# File 'lib/execjs/fastnode/external_piped_runtime.rb', line 32

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

#exec(context, source) ⇒ Object



28
29
30
# File 'lib/execjs/fastnode/external_piped_runtime.rb', line 28

def exec(context, source)
  command("exec", {context: context, source: source})
end

#startObject



36
37
38
39
40
41
42
# File 'lib/execjs/fastnode/external_piped_runtime.rb', line 36

def start
  return if started?
  @mutex.synchronize do
    # will double check started? with the lock held
    start_without_synchronization
  end
end

#started?Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/execjs/fastnode/external_piped_runtime.rb', line 20

def started?
  !!@stdin
end