def pop(self, number: int, ensure_even_length=False):
        """
        Pop number of elements. If there are not enough elements, all remaining elements are returned and the
        buffer is cleared afterwards. If buffer is empty, an empty numpy array is returned.

        If number is -1 (or any other value below zero) than complete buffer is returned
        """
        if ensure_even_length:
            number -= number % 2

        if len(self) == 0 or number == 0:
            return np.array([], dtype=np.complex64)

        if number < 0:
            # take everything
            number = len(self)
        else:
            number = min(number, len(self))

        with self.__data.get_lock():
            data = np.frombuffer(self.__data.get_obj(), dtype=np.complex64)

            result = np.empty(number, dtype=np.complex64)

            if self.left_index + number > len(data):
                end = len(data) - self.left_index
            else:
                end = number

            result[:end] = data[self.left_index:self.left_index + end]
            if end < number:
                result[end:] = data[:number-end]

        self.left_index += number
        self.__length.value -= number

        return result