Class: Isomorfeus::Speednode::Runtime
- Inherits:
-
ExecJS::Runtime
show all
- Defined in:
- lib/isomorfeus/speednode/runtime.rb,
lib/isomorfeus/speednode/runtime/vm.rb,
lib/isomorfeus/speednode/runtime/context.rb,
lib/isomorfeus/speednode/runtime/vm_command.rb
Defined Under Namespace
Classes: Context, VM, VMCommand
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
#permissive_bench, #permissive_compile, #permissive_eval, #permissive_exec
Constructor Details
#initialize(options) ⇒ Runtime
Returns a new instance of Runtime.
18
19
20
21
22
23
24
25
26
27
28
29
|
# File 'lib/isomorfeus/speednode/runtime.rb', line 18
def initialize(options)
@name = options[:name]
@binary = Isomorfeus::Speednode::NodeCommand.cached(options[:command])
@runner_path = options[:runner_path]
@vm = VM.new(binary: @binary, source_maps: '--enable-source-maps', runner_path: @runner_path)
@encoding = options[:encoding]
@deprecated = !!options[:deprecated]
@popen_options = {}
@popen_options[:external_encoding] = @encoding if @encoding
@popen_options[:internal_encoding] = ::Encoding.default_internal || 'UTF-8'
@contexts = {}
end
|
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
16
17
18
|
# File 'lib/isomorfeus/speednode/runtime.rb', line 16
def name
@name
end
|
#vm ⇒ Object
Returns the value of attribute vm.
16
17
18
|
# File 'lib/isomorfeus/speednode/runtime.rb', line 16
def vm
@vm
end
|
Class Method Details
.attach_proc(context_id, func, run_block) ⇒ Object
4
5
6
|
# File 'lib/isomorfeus/speednode/runtime.rb', line 4
def self.attach_proc(context_id, func, run_block)
attached_procs[context_id] = { func => run_block }
end
|
.attached_procs ⇒ Object
8
9
10
|
# File 'lib/isomorfeus/speednode/runtime.rb', line 8
def self.attached_procs
@attached_procs ||= {}
end
|
.responders ⇒ Object
12
13
14
|
# File 'lib/isomorfeus/speednode/runtime.rb', line 12
def self.responders
@responders ||= {}
end
|
Instance Method Details
#available? ⇒ Boolean
48
49
50
|
# File 'lib/isomorfeus/speednode/runtime.rb', line 48
def available?
@binary ? true : false
end
|
#deprecated? ⇒ Boolean
52
53
54
|
# File 'lib/isomorfeus/speednode/runtime.rb', line 52
def deprecated?
@deprecated
end
|
#register_context(uuid, context) ⇒ Object
31
32
33
|
# File 'lib/isomorfeus/speednode/runtime.rb', line 31
def register_context(uuid, context)
@contexts[uuid] = context
end
|
#stop_context(context) ⇒ Object
44
45
46
|
# File 'lib/isomorfeus/speednode/runtime.rb', line 44
def stop_context(context)
unregister_context(context.instance_variable_get(:@uuid))
end
|
#unregister_context(uuid) ⇒ Object
35
36
37
38
39
40
41
42
|
# File 'lib/isomorfeus/speednode/runtime.rb', line 35
def unregister_context(uuid)
context = @contexts.delete(uuid)
if context && @vm
ObjectSpace.undefine_finalizer(context)
_ok, cc = @vm.delete_context(uuid) rescue nil end
@vm.stop if @contexts.size == 0 && @vm.started?
end
|