Module: Poseidon::Cluster
- Defined in:
- lib/poseidon/cluster.rb
Constant Summary collapse
- MAX_INT32 =
0x7fffffff
- @@sem =
Mutex.new
- @@inc =
0
Class Method Summary collapse
-
.guid ⇒ String
private
An globally unique identifier.
-
.inc! ⇒ Integer
private
An incremented number.
Class Method Details
.guid ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns an globally unique identifier.
20 21 22 |
# File 'lib/poseidon/cluster.rb', line 20 def self.guid [::Socket.gethostname, ::Process.pid, ::Time.now.to_i, inc!].join("-") end |
.inc! ⇒ Integer
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns an incremented number.
14 15 16 |
# File 'lib/poseidon/cluster.rb', line 14 def self.inc! @@sem.synchronize { @@inc += 1; @@inc = 1 if @@inc > MAX_INT32; @@inc } end |