Class: Kameleoon::ClientReadiness
- Inherits:
-
Object
- Object
- Kameleoon::ClientReadiness
- Defined in:
- lib/kameleoon/client_readiness.rb
Instance Attribute Summary collapse
-
#is_initializing ⇒ Object
readonly
Returns the value of attribute is_initializing.
-
#success ⇒ Object
readonly
Returns the value of attribute success.
Instance Method Summary collapse
-
#initialize ⇒ ClientReadiness
constructor
A new instance of ClientReadiness.
- #reset ⇒ Object
- #set(success) ⇒ Object
- #wait ⇒ Object
Constructor Details
#initialize ⇒ ClientReadiness
Returns a new instance of ClientReadiness.
9 10 11 12 13 14 |
# File 'lib/kameleoon/client_readiness.rb', line 9 def initialize @is_initializing = false @success = false @condition = Concurrent::ReadWriteLock.new reset end |
Instance Attribute Details
#is_initializing ⇒ Object (readonly)
Returns the value of attribute is_initializing.
7 8 9 |
# File 'lib/kameleoon/client_readiness.rb', line 7 def is_initializing @is_initializing end |
#success ⇒ Object (readonly)
Returns the value of attribute success.
7 8 9 |
# File 'lib/kameleoon/client_readiness.rb', line 7 def success @success end |
Instance Method Details
#reset ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/kameleoon/client_readiness.rb', line 16 def reset @success = false unless @is_initializing @is_initializing = true @condition.acquire_write_lock end end |
#set(success) ⇒ Object
24 25 26 27 28 29 30 |
# File 'lib/kameleoon/client_readiness.rb', line 24 def set(success) @success = success if @is_initializing @condition.release_write_lock @is_initializing = false end end |
#wait ⇒ Object
32 33 34 35 36 37 38 |
# File 'lib/kameleoon/client_readiness.rb', line 32 def wait if @is_initializing @condition.acquire_read_lock @condition.release_read_lock end @success end |