Class: Rukawa::Context

Inherits:
Object
  • Object
show all
Defined in:
lib/rukawa/context.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(concurrency = nil) ⇒ Context

Returns a new instance of Context.



5
6
7
8
9
10
# File 'lib/rukawa/context.rb', line 5

def initialize(concurrency = nil)
  @concurrency = concurrency || Rukawa.config.concurrency
  @store = Concurrent::Hash.new
  @executor = Concurrent::CachedThreadPool.new
  @semaphore = Concurrent::Semaphore.new(@concurrency)
end

Instance Attribute Details

#concurrencyObject (readonly)

Returns the value of attribute concurrency.



3
4
5
# File 'lib/rukawa/context.rb', line 3

def concurrency
  @concurrency
end

#executorObject (readonly)

Returns the value of attribute executor.



3
4
5
# File 'lib/rukawa/context.rb', line 3

def executor
  @executor
end

#semaphoreObject (readonly)

Returns the value of attribute semaphore.



3
4
5
# File 'lib/rukawa/context.rb', line 3

def semaphore
  @semaphore
end

#storeObject (readonly)

Returns the value of attribute store.



3
4
5
# File 'lib/rukawa/context.rb', line 3

def store
  @store
end

Instance Method Details

#shutdownObject



12
13
14
# File 'lib/rukawa/context.rb', line 12

def shutdown
  @executor.shutdown if @executor.running?
end