use class variable for Mutex instead of Const
This commit is contained in:
parent
83ae172145
commit
27359dbf22
1 changed files with 7 additions and 2 deletions
|
@ -1,8 +1,13 @@
|
|||
# rubocop:disable Style/ClassVars
|
||||
|
||||
module Gitlab
|
||||
module Metrics
|
||||
module Concern
|
||||
extend ActiveSupport::Concern
|
||||
MUTEX = Mutex.new
|
||||
|
||||
included do
|
||||
@@_metric_provider_mutex = Mutex.new
|
||||
end
|
||||
|
||||
class_methods do
|
||||
def reload_metric!(name)
|
||||
|
@ -37,7 +42,7 @@ module Gitlab
|
|||
end
|
||||
|
||||
def synchronized_cache_fill(key)
|
||||
MUTEX.synchronize do
|
||||
@@_metric_provider_mutex.synchronize do
|
||||
@_metrics_provider_cache ||= {}
|
||||
@_metrics_provider_cache[key] ||= yield
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue