# Path: girlfriend/exception.py
# class InvalidArgumentException(GirlFriendSysException):
# 
#     """当函数输入的参数不正确时抛出此异常
#     """
#     pass


import threading
from girlfriend.exception import InvalidArgumentException
class CountDownLatch(object):

    """基于计数的闭锁实现
    """

    def __init__(self, count):
        if count <= 0:
            raise InvalidArgumentException(u"count参数必须为正整数")
        self._count = count
        self._condition = threading.Condition()

    def count_down(self):
        with self._condition:
            self._count -= 1
            if self._count <= 0:
                self._condition.notifyAll()

    def await(self):
        with self._condition:
            while self._count > 0:
                self._condition.wait()


class CyclicBarrier(object):

    """循环关卡实现
    """

    def __init__(self, count):
        if count <= 0:

# Path: girlfriend/exception.py
# class InvalidArgumentException(GirlFriendSysException):
# 
#     """当函数输入的参数不正确时抛出此异常
#     """
#     pass


# Path: girlfriend/util/concurrent.py
import threading
from girlfriend.exception import InvalidArgumentException

class CountDownLatch(object):

    """基于计数的闭锁实现
    """

    def __init__(self, count):
        if count <= 0:
            raise InvalidArgumentException(u"count参数必须为正整数")
        self._count = count
        self._condition = threading.Condition()

    def count_down(self):
        with self._condition:
            self._count -= 1
            if self._count <= 0:
                self._condition.notifyAll()

    def await(self):
        with self._condition:
            while self._count > 0:
                self._condition.wait()


class CyclicBarrier(object):

    """循环关卡实现
    """

    def __init__(self, count):
        if count <= 0:

            raise InvalidArgumentException(u"count参数必须为正整数")