Class: ConvenientService::Support::ThreadSafeCounter
- Inherits:
-
Counter
- Object
- Counter
- ConvenientService::Support::ThreadSafeCounter
show all
- Defined in:
- lib/convenient_service/support/thread_safe_counter.rb
Instance Attribute Summary
Attributes inherited from Counter
#current_value, #initial_value, #max_value, #min_value
Instance Method Summary
collapse
Constructor Details
#initialize ⇒ void
15
16
17
18
19
|
# File 'lib/convenient_service/support/thread_safe_counter.rb', line 15
def initialize(...)
super
@lock = ::Mutex.new
end
|
Instance Method Details
#bdecrement ⇒ Object
bdecrement
means boolean decrement. Works exactly in the same way as decrement
except returns a boolean value.
If decremented successfully then returns true
, otherwise - returns false
.
114
115
116
|
# File 'lib/convenient_service/support/thread_safe_counter.rb', line 114
def bdecrement(...)
@lock.synchronize { super }
end
|
#bincrement ⇒ Object
bincrement
means boolean increment. Works exactly in the same way as increment
except returns a boolean value.
If incremented successfully then returns true
, otherwise - returns false
.
72
73
74
|
# File 'lib/convenient_service/support/thread_safe_counter.rb', line 72
def bincrement(...)
@lock.synchronize { super }
end
|
#current_value= ⇒ Object
30
31
32
|
# File 'lib/convenient_service/support/thread_safe_counter.rb', line 30
def current_value=(...)
@lock.synchronize { super }
end
|
#decrement ⇒ Object
85
86
87
|
# File 'lib/convenient_service/support/thread_safe_counter.rb', line 85
def decrement(...)
@lock.synchronize { super }
end
|
#decrement! ⇒ Object
98
99
100
|
# File 'lib/convenient_service/support/thread_safe_counter.rb', line 98
def decrement!(...)
@lock.synchronize { super }
end
|
#increment ⇒ Object
43
44
45
|
# File 'lib/convenient_service/support/thread_safe_counter.rb', line 43
def increment(...)
@lock.synchronize { super }
end
|
#increment! ⇒ Object
56
57
58
|
# File 'lib/convenient_service/support/thread_safe_counter.rb', line 56
def increment!(...)
@lock.synchronize { super }
end
|
#reset ⇒ Object
124
125
126
|
# File 'lib/convenient_service/support/thread_safe_counter.rb', line 124
def reset(...)
@lock.synchronize { super }
end
|