コード例 #1
0
 def __init__(self):
     self.__lock = pm.Mutex('PythonLock')
     self.__cvar = pm.ConditionVar(self.__lock)
     self.__locked = False
コード例 #2
0
        finally:
            self.__lock.release()

    def locked(self):
        return self.__locked

    __enter__ = acquire

    def __exit__(self, t, v, tb):
        self.release()


_threads = {}
_nextThreadId = 0
_threadsLock = pm.Mutex('thread._threadsLock')


def start_new_thread(function, args, kwargs={}, name=None):
    def threadFunc(threadId, function=function, args=args, kwargs=kwargs):
        try:
            try:
                function(*args, **kwargs)
            except SystemExit:
                pass

        finally:
            _remove_thread_id(threadId)

    global _nextThreadId
    _threadsLock.acquire()