Source

CherryPy / cherrypy / process / unix_threading / _native_event.py

The branch '769-unixwait' does not exist.
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()