the class will instance one time when use
178608
public function singleton($contract, $class, $args = [])
    {
        $reflect = new \ReflectionClass($class);
        $instance = $reflect->newInstanceArgs($args);

        $this->bindings[$contract] = [
            'type' => 'singleton',
            'instance' => $instance,
            'class' => $class,
            'args' => $args
        ];

        if (!class_exists($contract, false)) {
            eval("class {$contract} extends \Hades\Container\Facade {} ");
        }
    }
112355
def once(dispatcher, event, handle, *args):
    

    def shell(dispatcher, *args):
        try:
            handle(dispatcher, *args)
        except Exception as e:
            raise e
        finally:
            dispatcher.del_map(event, shell)
    dispatcher.add_map(event, shell, *args)
695956
Object getClassInstance() throws UtilEvalError {
        if (this.classInstance != null)
            return this.classInstance;
        if (this.classStatic != null
        // || (getParent()!=null && getParent().classStatic != null)
       )
            throw new UtilEvalError(
                    "Can't refer to class instance from static context.");
        else
            throw new InterpreterError(
                    "Can't resolve class instance 'this' in: " + this);
    }
292020
public static void setInstance(OkHttpClient client) throws GuildWars2Exception {
		if (instance != null)
			throw new GuildWars2Exception(ErrorCode.Other, "Instance already initialized");
		instance = new GuildWars2(client);
	}
732183
def singleton_init_by(init_fn=None):
    

    if not init_fn:
        def wrap_init(origin_init):
            return origin_init
    else:
        def wrap_init(origin_init):
            def __init__(self):
                origin_init(self)
                init_fn(self)

            return __init__

    def inner(cls_def: type):
        if not hasattr(cls_def, '__instancecheck__') or isinstance(cls_def.__instancecheck__,
                                                                   (types.BuiltinMethodType, _slot_wrapper)):
            def __instancecheck__(self, instance):
                return instance is self

            cls_def.__instancecheck__ = __instancecheck__

        _origin_init = cls_def.__init__
        cls_def.__init__ = wrap_init(_origin_init)

        return cls_def()

    return inner
472679
def once(event, &block)
      add_listener(event) do |*args, &callback|
        block.call(*args, &callback)
        :delete
      end
    end
173141
def set_instance(self, thing: type, value, overwrite=False):
        
        if thing in self.instances and not overwrite:
            raise DiayException('instance for %r already exists' % thing)
        self.instances[thing] = value
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
654274
def get_listener_instance(self, cls):
        
        with self._lock:
            for listener in self._listeners:
                if isinstance(listener, cls):
                    return listener
24446
def instance():
        
        if not hasattr(IOLoop, "_instance"):
            with IOLoop._instance_lock:
                if not hasattr(IOLoop, "_instance"):
                    # New instance after double check
                    IOLoop._instance = IOLoop()
        return IOLoop._instance
707837
private static Object newInstance(Class<?> clazz) {
        Object instance = null;
        try {
            instance = clazz.newInstance();
        } catch (Exception ex) {
            log.error("Error loading class: {}", clazz.getName(), ex);
        }
        return instance;
    }
324534
protected T createInstance() {
		try {
			return targetClass.newInstance();
		} catch (InstantiationException e) {
			throw new RuntimeException(e);
		} catch (IllegalAccessException e) {
			throw new RuntimeException(e);
		}
	}
1023926
def _onInstanceAttribute(self, name, line, pos, absPosition, level):
        """"""
        # Instance attributes may appear in member functions only so we already
        # have a function on the stack of objects. To get the class object one
        # more step is required so we -1 here.
        attributes = self.objectsStack[level - 1].instanceAttributes
        for item in attributes:
            if item.name == name:
                return
        attributes.append(InstanceAttribute(name, line, pos, absPosition))
1363624
def once(func):
    """"""
    lock = threading.Lock()

    def new_func(*args, **kwargs):
        if new_func.called:
            return
        with lock:
            if new_func.called:
                return
            rv = func(*args, **kwargs)
            new_func.called = True
            return rv

    new_func = update_wrapper(new_func, func)
    new_func.called = False
    return new_func
1143501
def once(self, event, callback):
        ''
        self._once_events.add(event)
        self.on(event, callback)
1327223
static function GetInstance()
	{
		if (!self::$IS_INITIALIZED) self::Init();

		if (!self::$INSTANCE instanceof self) self::$INSTANCE = new self;

		return self::$INSTANCE;
	}
773614
public static void initialize(SingletonProvider instance) {
        synchronized (SingletonProvider.class) {
            if (INSTANCE == null) {
                INSTANCE = instance;
            } else {
                throw new RuntimeException("SingletonProvider is already initialized with " + INSTANCE);
            }
        }
    }