Skip to content

Commit

Permalink
fix(support): move lock to thread safe counter
Browse files Browse the repository at this point in the history
  • Loading branch information
marian13 committed May 14, 2023
1 parent 7cff9b1 commit b90f2e7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
1 change: 0 additions & 1 deletion lib/convenient_service/support/counter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ def initialize(initial_value: 0, min_value: -::Float::INFINITY, max_value: ::Flo
@current_value = initial_value
@min_value = min_value
@max_value = max_value
@lock = ::Mutex.new
end

##
Expand Down
9 changes: 9 additions & 0 deletions lib/convenient_service/support/thread_safe_counter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,15 @@ module Support
# - https://en.wikipedia.org/wiki/Semaphore_(programming)
#
class ThreadSafeCounter < Support::Counter
##
# @return [void]
#
def initialize(...)
super

@lock = ::Mutex.new
end

##
# @see ConvenientService::Support::Counter#current_value=
#
Expand Down

0 comments on commit b90f2e7

Please sign in to comment.