Class: Mila::Benchmark::Mixin::V8Session
- Inherits:
-
Object
- Object
- Mila::Benchmark::Mixin::V8Session
- Defined in:
- lib/mila/benchmark/mixin.rb
Instance Method Summary collapse
- #call(*args) ⇒ Object
- #context ⇒ Object
- #eval_inline(&block) ⇒ Object
-
#initialize ⇒ V8Session
constructor
A new instance of V8Session.
- #load_bundleable_lib(lib) ⇒ Object
Constructor Details
#initialize ⇒ V8Session
Returns a new instance of V8Session.
28 29 30 31 32 33 |
# File 'lib/mila/benchmark/mixin.rb', line 28 def initialize @queue = Queue.new @thread = Thread.new { create_context } @body = nil @has_source = false end |
Instance Method Details
#call(*args) ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/mila/benchmark/mixin.rb', line 52 def call(*args) case args in [function_name, args_array] function_name = function_name.to_s in [args_array] function_name = @body.entrypoint_name else raise ArgumentError, 'Invalid arguments' end context.call(function_name, args_array) end |
#context ⇒ Object
35 36 37 |
# File 'lib/mila/benchmark/mixin.rb', line 35 def context @context ||= @queue.pop end |