method

__init__

Importance_0
v2_5_5 - Show latest stable - 0 notes - Class: Singleton
__init__(klass) public

No documentation

This method has no description. You can help the Ruby community by adding new notes.

Hide source
# File lib/singleton.rb, line 132
    def __init__(klass) # :nodoc:
      klass.instance_eval {
        @singleton__instance__ = nil
        @singleton__mutex__ = Thread::Mutex.new
      }
      def klass.instance # :nodoc:
        return @singleton__instance__ if @singleton__instance__
        @singleton__mutex__.synchronize {
          return @singleton__instance__ if @singleton__instance__
          @singleton__instance__ = new()
        }
        @singleton__instance__
      end
      klass
    end
Register or log in to add new notes.