Sha256: 8fafe6280a0600e58d7136463229f6970a75dde69136c94e86ec9ae8fa1d4de0
Contents?: true
Size: 888 Bytes
Versions: 20
Compression:
Stored size: 888 Bytes
Contents
require 'asir/uuid' require 'thread' # Mutex module ASIR # !SLIDE # Message Identity # module Identity attr_accessor :identifier, :timestamp # Optional: Opaque data about the Client that created the Message. attr_accessor :client # Optional: Opaque data about the Service that handled the Result. attr_accessor :server # Creates a thread-safe unique identifier. def create_identifier! @identifier ||= @@identifier_mutex.synchronize do if @@uuid_pid != $$ @@uuid_pid = $$ @@uuid = nil end "#{@@counter += 1}-#{@@uuid ||= ::ASIR::UUID.generate}".freeze end end @@counter ||= 0; @@uuid ||= nil; @@uuid_pid = nil; @@identifier_mutex ||= Mutex.new # Creates a timestamp. def create_timestamp! @timestamp ||= ::Time.now.gmtime end end end
Version data entries
20 entries across 20 versions & 1 rubygems