Class: RBus::Message::SerialGenerator

Inherits:
Object
  • Object
show all
Includes:
MonitorMixin, Singleton
Defined in:
lib/rbus/message/serial_generator.rb

Overview

Generate a thread-safe, unique serial number for Messages.

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeSerialGenerator

Returns a new instance of SerialGenerator.



34
35
36
37
# File 'lib/rbus/message/serial_generator.rb', line 34

def initialize
  @serial = 0
  super
end

Class Method Details

.get_uniqueObject



38
39
40
# File 'lib/rbus/message/serial_generator.rb', line 38

def self.get_unique
  instance.get_next
end

Instance Method Details

#get_nextObject



41
42
43
44
45
# File 'lib/rbus/message/serial_generator.rb', line 41

def get_next
  synchronize do
    @serial += 1
  end
end