Esempio n. 1
0
class Barrier():
    def __init__(self, count=1):
        self.count = int(count)
        self.current = 0
        self.condition = DCondition()

    def wait(self, _concoord_command):
        self.condition.acquire(_concoord_command)
        self.current += 1
        if self.current != self.count:
            self.condition.wait(_concoord_command)
        else:
            self.current = 0
            self.condition.notifyAll(_concoord_command)
        self.condition.release(_concoord_command)

    def __str__(self):
        return "<%s object>" % (self.__class__.__name__)
Esempio n. 2
0
class Barrier():
    def __init__(self, count=1):
        self.count = int(count)
        self.current = 0
        self.condition = DCondition()

    def wait(self, _concoord_command):
        self.condition.acquire(_concoord_command)
        self.current += 1
        if self.current != self.count:
            self.condition.wait(_concoord_command)
        else:
            self.current = 0
            self.condition.notifyAll(_concoord_command)
        self.condition.release(_concoord_command)

    def __str__(self):
        return "<%s object>" % (self.__class__.__name__)
Esempio n. 3
0
class Barrier():
    def __init__(self, count=1, **kwargs):
        self.count = int(count)
        self.current = 0
        self.condition = DCondition()

    def wait(self, **kwargs):
        self.condition.acquire(kwargs)
        self.current += 1
        if self.current != self.count:
            self.condition.wait(kwargs)
        else:
            self.current = 0
            self.condition.notifyAll(kwargs)
        self.condition.release(kwargs)
        
    def __str__(self, **kwargs):
        return "<%s object>" % (self.__class__.__name__)
Esempio n. 4
0
class Condition():
    """Lock object that supports following functions:
    - acquire: locks the object
    - release: unlocks the object
    """
    def __init__(self, lock=None, **kwargs):
        self.condition = DCondition()

    def __repr__(self, **kwargs):
        return repr(self.condition)

    def acquire(self, **kwargs):
        try:
            self.condition.acquire(kwargs)
        except Exception as e:
            raise e
        
    def release(self, **kwargs):
        try:
            self.condition.release(kwargs)
        except Exception as e:
            raise e
        
    def wait(self, **kwargs):
        try:
            self.condition.wait(kwargs)
        except Exception as e:
            raise e
        
    def notify(self, **kwargs):
        try:
            self.condition.notify(kwargs)
        except Exception as e:
            raise e

    def notifyAll(self, **kwargs):
        try:
            self.condition.notifyAll(kwargs)
        except Exception as e:
            raise e

    def __str__(self, **kwargs):
        return str(self.condition)
Esempio n. 5
0
class Condition():
    def __init__(self, lock=None):
        self.condition = DCondition()

    def __repr__(self):
        return repr(self.condition)

    def acquire(self, _concoord_command):
        try:
            self.condition.acquire(_concoord_command)
        except Exception as e:
            raise e

    def release(self, _concoord_command):
        try:
            self.condition.release(_concoord_command)
        except Exception as e:
            raise e

    def wait(self, _concoord_command):
        try:
            self.condition.wait(_concoord_command)
        except Exception as e:
            raise e

    def notify(self, _concoord_command):
        try:
            self.condition.notify(_concoord_command)
        except Exception as e:
            raise e

    def notifyAll(self, _concoord_command):
        try:
            self.condition.notifyAll(_concoord_command)
        except Exception as e:
            raise e

    def __str__(self):
        return str(self.condition)
Esempio n. 6
0
class Condition():
    def __init__(self, lock=None):
        self.condition = DCondition()

    def __repr__(self):
        return repr(self.condition)

    def acquire(self, _concoord_command):
        try:
            self.condition.acquire(_concoord_command)
        except Exception as e:
            raise e

    def release(self, _concoord_command):
        try:
            self.condition.release(_concoord_command)
        except Exception as e:
            raise e

    def wait(self, _concoord_command):
        try:
            self.condition.wait(_concoord_command)
        except Exception as e:
            raise e

    def notify(self, _concoord_command):
        try:
            self.condition.notify(_concoord_command)
        except Exception as e:
            raise e

    def notifyAll(self, _concoord_command):
        try:
            self.condition.notifyAll(_concoord_command)
        except Exception as e:
            raise e

    def __str__(self):
        return str(self.condition)