Class: Sqreen::Js::ContextPool

Inherits:
Object
  • Object
show all
Defined in:
lib/sqreen/js/context_pool.rb

Instance Method Summary collapse

Constructor Details

#initializeContextPool

Returns a new instance of ContextPool.



11
12
13
14
15
# File 'lib/sqreen/js/context_pool.rb', line 11

def initialize
  @mutex = Mutex.new
  @total_ctxs = 0
  @contexts = []
end

Instance Method Details

#with_context(&block) ⇒ Object



17
18
19
20
21
22
23
24
# File 'lib/sqreen/js/context_pool.rb', line 17

def with_context(&block)
  isolate = context
  begin
    block[isolate]
  ensure
    give_back_context isolate
  end
end