Class: Sqreen::Js::ThreadLocalExecJsRunnable

Inherits:
ExecutableJs show all
Defined in:
lib/sqreen/js/thread_local_exec_js_runnable.rb

Instance Method Summary collapse

Constructor Details

#initialize(code) ⇒ ThreadLocalExecJsRunnable

Returns a new instance of ThreadLocalExecJsRunnable.



13
14
15
16
17
18
# File 'lib/sqreen/js/thread_local_exec_js_runnable.rb', line 13

def initialize(code)
  @code = code
  @tl_key = "SQREEN_EXECJS_CONTEXT_#{object_id}".freeze
  @runtimes = [] # place where to keep strong references
  @runtimes_mutex = Mutex.new
end

Instance Method Details

#run_js_cb(cbname, _budget, arguments) ⇒ Object



20
21
22
# File 'lib/sqreen/js/thread_local_exec_js_runnable.rb', line 20

def run_js_cb(cbname, _budget, arguments)
  tl_exec_js_runnable.call(cbname, *arguments)
end

#with_runtimes_mutexObject



24
25
26
# File 'lib/sqreen/js/thread_local_exec_js_runnable.rb', line 24

def with_runtimes_mutex
  @runtimes_mutex.synchronize { yield }
end