def __init__(self, to_notify = None, as_iterator = True):
        """
        \param to_notify ApplyResult object to notify when all the
        results we're waiting for become available. Can be None.
        \param as_iterator boolean telling whether the result value
        set on to_notify should be an iterator (available as soon as 1
        result arrived) or a list (available only after the last
        result arrived)
        """
        AbstractResultCollector.__init__(self, to_notify)
        self._results     = []
        self._lock        = threading.Lock()
        self._remaining   = 0
        self._as_iterator = as_iterator

        \param to_notify ApplyResult object to notify when all the
        results we're waiting for become available. Can be None.
        \param as_iterator boolean telling whether the result value
        set on to_notify should be an iterator (available as soon as 1
        result arrived) or a list (available only after the last
        result arrived)
        
recipes/Python/576519_Thread_pool_same_API/recipe-576519.py