Class: Rukawa::Context
- Inherits:
-
Object
- Object
- Rukawa::Context
- Defined in:
- lib/rukawa/context.rb
Instance Attribute Summary collapse
-
#concurrency ⇒ Object
readonly
Returns the value of attribute concurrency.
-
#executor ⇒ Object
readonly
Returns the value of attribute executor.
-
#semaphore ⇒ Object
readonly
Returns the value of attribute semaphore.
-
#store ⇒ Object
readonly
Returns the value of attribute store.
Instance Method Summary collapse
-
#initialize(concurrency = nil) ⇒ Context
constructor
A new instance of Context.
- #shutdown ⇒ Object
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
#concurrency ⇒ Object (readonly)
Returns the value of attribute concurrency.
3 4 5 |
# File 'lib/rukawa/context.rb', line 3 def concurrency @concurrency end |
#executor ⇒ Object (readonly)
Returns the value of attribute executor.
3 4 5 |
# File 'lib/rukawa/context.rb', line 3 def executor @executor end |
#semaphore ⇒ Object (readonly)
Returns the value of attribute semaphore.
3 4 5 |
# File 'lib/rukawa/context.rb', line 3 def semaphore @semaphore end |
#store ⇒ Object (readonly)
Returns the value of attribute store.
3 4 5 |
# File 'lib/rukawa/context.rb', line 3 def store @store end |
Instance Method Details
#shutdown ⇒ Object
12 13 14 |
# File 'lib/rukawa/context.rb', line 12 def shutdown @executor.shutdown if @executor.running? end |