Class: Google::Protobuf::Internal::AtomicCounter
- 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
- #get_and_increment ⇒ Object
-
#initialize ⇒ AtomicCounter
constructor
A new instance of AtomicCounter.
Constructor Details
#initialize ⇒ AtomicCounter
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_increment ⇒ Object
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 |