This service model enforces a singleton constraint on the service point it protects. That is to say, whenever the instance method of this model is called, it will always return the same instance of the service point.

Methods
Public Class methods
new( service_point )

Create a new SingletonServiceModel on the given service point.

    # File lib/copland/models/singleton.rb, line 49
49:       def initialize( service_point )
50:         super
51:         @mutex = QueryableMutex.new
52:       end
Public Instance methods
instance( &init )

Return the singleton instance of the service point. This is thread safe.

    # File lib/copland/models/singleton.rb, line 56
56:       def instance( &init )
57:         return @instance if @instance
58: 
59:         if @mutex.self_locked?
60:           raise CoplandException,
61:             "circular dependency on #{service_point.full_name} detected"
62:         end
63: 
64:         @mutex.synchronize do
65:           return @instance if @instance
66:           new_instance( &init )
67:           return @instance
68:         end
69:       end