Sha256: 475c708f75403427c02c07f8530bd248f15997e69457303de5bab890a690a96b
Contents?: true
Size: 532 Bytes
Versions: 136
Compression:
Stored size: 532 Bytes
Contents
require 'thread' module Vagrant module Util # Atomic counter implementation. This is useful for incrementing # a counter which is guaranteed to only be used once in its class. module Counter def get_and_update_counter(name=nil) name ||= :global mutex.synchronize do @__counter ||= Hash.new(1) result = @__counter[name] @__counter[name] += 1 result end end def mutex @__counter_mutex ||= Mutex.new end end end end
Version data entries
136 entries across 129 versions & 19 rubygems