Singleton.py
Go to the documentation of this file.
1 #/usr/bin/env python
2 # -*- coding: euc-jp -*-
3 
4 
18 
19 import thread
20 
21 
31 class Singleton(object):
32  __lockObj = thread.allocate_lock()
33  __instance = None
34 
35  def __new__(self, *args, **kargs):
36  return self.instance(*args, **kargs)
37 
38 
39  def __init__(self, *args, **kargs):
40  self.instance(*args, **kargs)
41 
42 
43  def instance(self, *args, **kargs):
44  self.__lockObj.acquire()
45  try:
46  if self.__instance is None:
47  self.__instance = object.__new__(self, *args, **kargs)
48 
49  finally:
50  self.__lockObj.release()
51 
52  return self.__instance
53 
54  instance = classmethod(instance)
55 
def __new__(self, args, kargs)
Definition: Singleton.py:35
def __init__(self, args, kargs)
Definition: Singleton.py:39


openrtm_aist_python
Author(s): Shinji Kurihara
autogenerated on Thu Jun 6 2019 19:11:34