Class: Google::Protobuf::Internal::AtomicCounter

Inherits:
Object
  • Object
show all
Defined in:
lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/google-protobuf-3.21.12-x86_64-linux/lib/google/protobuf/descriptor_dsl.rb

Instance Method Summary collapse

Constructor Details

#initializeAtomicCounter

Returns a new instance of AtomicCounter.



18
19
20
21
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/google-protobuf-3.21.12-x86_64-linux/lib/google/protobuf/descriptor_dsl.rb', line 18

def initialize
  @n = 0
  @mu = Mutex.new
end

Instance Method Details

#get_and_incrementObject



23
24
25
26
27
28
29
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/google-protobuf-3.21.12-x86_64-linux/lib/google/protobuf/descriptor_dsl.rb', line 23

def get_and_increment
  n = @n
  @mu.synchronize {
    @n += 1
  }
  return n
end