For use like a singleton, return the existing instance of the object
        or a new instance
423767
def default_instance(cls):
        
        if cls._instance is None:
            with cls._instance_lock:
                if cls._instance is None:
                    cls._instance = FlowsLogger()

        return cls._instance
1221319
def instance(cls):
        

        if not hasattr(cls, "_instance") or cls._instance is None:
            cls._instance = cls()
        return cls._instance
746684
def singleton(wrapped, _, args, kwargs):
    
    if wrapped not in _INSTANCES:
        _INSTANCES[wrapped] = wrapped(*args, **kwargs)
    return _INSTANCES[wrapped]
883945
def new(cls, data=None):
		
		obj = cls()
		if data is not None:
			obj.update(data)
		return obj
628995
def singleton_per_scope(_cls, _scope=None, _renew=False, *args, **kwargs):
    """"""

    result = None

    singletons = SINGLETONS_PER_SCOPES.setdefault(_scope, {})

    if _renew or _cls not in singletons:
        singletons[_cls] = _cls(*args, **kwargs)

    result = singletons[_cls]

    return result
292033
function() {
          return any(this.calls, function(call){
            return self.expectedResult.an_instance_of ?
                     call.result.constructor == self.expectedResult.an_instance_of:
                       equal(self.expectedResult, call.result)
          })
        }
909090
def instance(*args, **kwargs):
        

        if not hasattr(Config, "_instance") or Config._instance is None:
            Config._instance = Config(*args, **kwargs)
        return Config._instance
107583
def get_or_create(cls, name):
        
        obj = cls.query.filter_by(name=name).one_or_none()
        if obj:
            return obj
        try:
            with session.begin_nested():
                obj = cls(name=name)
                session.add(obj)
                session.flush()
            return obj
        except IntegrityError:
            log.debug('Collision when adding %s(name="%s"), returning existing object',
                      cls.__name__, name)
            return cls.query.filter_by(name=name).one()
390085
def get_instance(self, cls):
        """"""
        binding = self._bindings.get(cls)
        if binding:
            return binding()

        # Try to create a runtime binding.
        with _BINDING_LOCK:
            binding = self._bindings.get(cls)
            if binding:
                return binding()

            if not self._bind_in_runtime:
                raise InjectorException('No binding was found for key=%s' % cls)

            if not callable(cls):
                raise InjectorException(
                    'Cannot create a runtime binding, the key is not callable, key=%s' % cls)

            instance = cls()
            self._bindings[cls] = lambda: instance

            logger.debug('Created a runtime binding for key=%s, instance=%s', cls, instance)
            return instance
96422
function get_or_create() {
                if (locked) {
                    setTimeout(wait, 100);
                } else {
                    locked = true;

                    if (phantom_instance != null) {
                        locked = false;
                        resolve(phantom_instance);
                    } else {
                        phantom.create().then((instance) => {
                            phantom_instance = instance;
                            locked = false;
                            resolve(instance);
                        });
                    }
                }
            }
39171
def clone(self):
        

        p = type(self)(self.id)
        p.hooks = list(self.hooks)
        p.instance = self.instance
        return p
819749
public static function instance($newInstance = null)
    {
        static $instance;

        if ($newInstance instanceof self) {
            $instance = $newInstance;
        }

        if (!($instance instanceof self)) {
            $instance = new self();
        }

        return $instance;
    }
1051547
def instance(cls, *args, **kwgs):
        """"""
        if not hasattr(cls, "_instance"):
            cls._instance = cls(*args, **kwgs)
        return cls._instance
229739
def _instance_callable(obj):
    """"""
    if not isinstance(obj, ClassTypes):
        # already an instance
        return getattr(obj, '__call__', None) is not None

    if six.PY3:
        # *could* be broken by a class overriding __mro__ or __dict__ via
        # a metaclass
        for base in (obj,) + obj.__mro__:
            if base.__dict__.get('__call__') is not None:
                return True
    else:
        klass = obj
        # uses __bases__ instead of __mro__ so that we work with old style classes
        if klass.__dict__.get('__call__') is not None:
            return True

        for base in klass.__bases__:
            if _instance_callable(base):
                return True
    return False
1182255
def instance(cls, name):
        
        if not cls._instance.get(name):
            model_name = name.split('.')
            ins_name = '.'.join(
                ['models', model_name[0], 'model', model_name[1]])
            cls._instance[name] = cls.import_model(ins_name)()

        return cls._instance[name]
890159
public static PojoUtil getInstance() {

    if (instance == null) {
      PojoUtilImpl impl = null;
      synchronized (PojoUtilImpl.class) {
        if (instance == null) {
          impl = new PojoUtilImpl();
          impl.initialize();
          instance = impl;
        }
      }
    }
    return instance;
  }
559527
def select
      new_instance = self.class.new
      if block_given?
        @data.each { |k,v| new_instance.data[k] = v if yield(k,v) }
      end
      return new_instance
    end