# Path: coolamqp/utils.py
# IMPORT_ERRORS = (ModuleNotFoundError, ImportError)
# IMPORT_ERRORS = (ImportError, )
# def prctl_set_name(name):


from abc import ABCMeta, abstractmethod
from coolamqp.utils import monotonic
import heapq
import typing as tp
import six


class BaseListener(object):
    __metaclass__ = ABCMeta

    def __init__(self):
        self.fd_to_sock = {}    # type: tp.Dict[int, BaseSocket]
        self.time_events = []  # type: tp.List[tp.Tuple[float, int, tp.Callable[[], None]]]

    def do_timer_events(self):
        # Timer events
        mono = monotonic()
        while len(self.time_events) > 0 and (self.time_events[0][0] < mono):
            ts, fd, callback = heapq.heappop(self.time_events)

# Path: coolamqp/utils.py
# IMPORT_ERRORS = (ModuleNotFoundError, ImportError)
# IMPORT_ERRORS = (ImportError, )
# def prctl_set_name(name):


# Path: coolamqp/uplink/listener/base_listener.py
from abc import ABCMeta, abstractmethod
from coolamqp.utils import monotonic
import heapq
import typing as tp
import six



class BaseListener(object):
    __metaclass__ = ABCMeta

    def __init__(self):
        self.fd_to_sock = {}    # type: tp.Dict[int, BaseSocket]
        self.time_events = []  # type: tp.List[tp.Tuple[float, int, tp.Callable[[], None]]]

    def do_timer_events(self):
        # Timer events
        mono = monotonic()
        while len(self.time_events) > 0 and (self.time_events[0][0] < mono):
            ts, fd, callback = heapq.heappop(self.time_events)

            callback()