Commit 27359dbf authored by Pawel Chojnacki's avatar Pawel Chojnacki

use class variable for Mutex instead of Const

parent 83ae1721
# rubocop:disable Style/ClassVars
module Gitlab module Gitlab
module Metrics module Metrics
module Concern module Concern
extend ActiveSupport::Concern extend ActiveSupport::Concern
MUTEX = Mutex.new
included do
@@_metric_provider_mutex = Mutex.new
end
class_methods do class_methods do
def reload_metric!(name) def reload_metric!(name)
...@@ -37,7 +42,7 @@ module Gitlab ...@@ -37,7 +42,7 @@ module Gitlab
end end
def synchronized_cache_fill(key) def synchronized_cache_fill(key)
MUTEX.synchronize do @@_metric_provider_mutex.synchronize do
@_metrics_provider_cache ||= {} @_metrics_provider_cache ||= {}
@_metrics_provider_cache[key] ||= yield @_metrics_provider_cache[key] ||= yield
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment