import abc

from typing import Any


class CancellationToken(abc.ABC):
    """ 取消令牌 """
    @abc.abstractmethod
    def is_canceled(self) -> bool:
        """ 是否取消 """
        ...


class ResultCollector(abc.ABC):
    """ 结果收集器 """
    @abc.abstractmethod
    def collect(self, result: Any) -> None:
        """ 收集结果 """
        ...

    @abc.abstractmethod
    def close(self) -> None:
        """ 关闭收集器 """
        ...
