Class: ConvenientService::Support::ThreadSafeCounter

Inherits:
Counter
  • Object
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

#initializevoid



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

#bdecrementObject

‘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`.

See Also:



114
115
116
# File 'lib/convenient_service/support/thread_safe_counter.rb', line 114

def bdecrement(...)
  @lock.synchronize { super }
end

#bincrementObject

‘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`.

See Also:



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

#decrementObject

See Also:



85
86
87
# File 'lib/convenient_service/support/thread_safe_counter.rb', line 85

def decrement(...)
  @lock.synchronize { super }
end

#decrement!Object

See Also:



98
99
100
# File 'lib/convenient_service/support/thread_safe_counter.rb', line 98

def decrement!(...)
  @lock.synchronize { super }
end

#incrementObject

See Also:



43
44
45
# File 'lib/convenient_service/support/thread_safe_counter.rb', line 43

def increment(...)
  @lock.synchronize { super }
end

#increment!Object

See Also:



56
57
58
# File 'lib/convenient_service/support/thread_safe_counter.rb', line 56

def increment!(...)
  @lock.synchronize { super }
end

#resetObject

See Also:



124
125
126
# File 'lib/convenient_service/support/thread_safe_counter.rb', line 124

def reset(...)
  @lock.synchronize { super }
end