import logging
from concurrent.futures import ThreadPoolExecutor

from ._HandleMessageStrategy import HandleMessageStrategy

logger = logging.getLogger(__name__)


class ThreadPoolExecutorHandleMessageStrategy(HandleMessageStrategy):
    def __init__(
        self,                       # type: ThreadPoolExecutorHandleMessageStrategy
        thread_pool_executor,       # type: ThreadPoolExecutor
    ):
        self.thread_pool_executor = thread_pool_executor

    def handle_message(self, executor, message):
        self.thread_pool_executor.submit(executor.handle_message, message)
