Class: ExecJS::FastNode::ExternalPipedRuntime::VM
- Inherits:
-
Object
- Object
- ExecJS::FastNode::ExternalPipedRuntime::VM
- Defined in:
- lib/execjs/fastnode/external_piped_runtime.rb
Instance Attribute Summary collapse
-
#stdin ⇒ Object
readonly
Returns the value of attribute stdin.
-
#stdout ⇒ Object
readonly
Returns the value of attribute stdout.
Class Method Summary collapse
Instance Method Summary collapse
- #delete_context(context) ⇒ Object
- #exec(context, source) ⇒ Object
-
#initialize(options) ⇒ VM
constructor
A new instance of VM.
- #start ⇒ Object
- #started? ⇒ Boolean
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() @mutex = Mutex.new @stdin = @stdout = @wait_thr = nil = end |
Instance Attribute Details
#stdin ⇒ Object (readonly)
Returns the value of attribute stdin.
12 13 14 |
# File 'lib/execjs/fastnode/external_piped_runtime.rb', line 12 def stdin @stdin end |
#stdout ⇒ Object (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 |
#start ⇒ Object
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
20 21 22 |
# File 'lib/execjs/fastnode/external_piped_runtime.rb', line 20 def started? !!@stdin end |