Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import threading
- from unix_threading import _pthread_cond
- class NativeEvent(object):
- def __init__(self):
- self.__cond = _pthread_cond.Condition()
- self.__flag = False
- def isSet(self):
- return self.__flag
- def set(self):
- self.__cond.acquire()
- try:
- self.__flag = True
- self.__cond.notifyAll()
- finally:
- self.__cond.release()
- def clear(self):
- self.__cond.acquire()
- try:
- self.__flag = False
- finally:
- self.__cond.release()
- def wait(self, timeout=None):
- self.__cond.acquire()
- try:
- if not self.__flag:
- self.__cond.wait(timeout)
- finally:
- self.__cond.release()
Add Comment
Please, Sign In to add comment