UNISTDX_IO_POLLER
class sys::event_poller

File descriptor poller.

  • File descriptor poller implemented with epoll_create1(2) system call having condition variable-like interface.
  • The poller has condition variable interface for waiting and notifying.

Types
  • using iterator = value_type *

    Container iterator type.

  • using value_type = container_type::value_type

    Container element type.

Fields
  • const typedef value_type * const_iterator

    Container const iterator type.

Methods
  • template <class Lock, class Clock, class Duration, class Pred>
    wait_until(Lock & lock, const std::chrono::time_point< Clock, Duration > & tp, Pred pred) -> bool

    Wait for events to occur until specified time dur unlocking lock for the duration of the wait until predicate pred becomes true or timeout occurs.

    • If pred is true upon the call to this method no waiting or unlocking is done
    • The mutex is locked when checking for the predicate.

    Return
    predicate value
  • template <class Lock, class Clock, class Duration>
    wait_until(Lock & lock, const std::chrono::time_point< Clock, Duration > & tp) -> std::cv_status

    Wait for events to occur until specified time tp unlocking lock for the duration of the wait.

  • template <class Lock, class Duration, class Pred>
    wait_until(Lock & lock, const time_point< Duration > & tp, Pred pred) -> bool

    Wait for events to occur until specified time tp unlocking lock for the duration of the wait until predicate pred becomes true.

    • If pred is true upon the call to this method no waiting or unlocking is done
    • The mutex is locked when checking for the predicate.

    Return
    predicate value
  • template <class Lock, class Duration>
    wait_until(Lock & lock, const time_point< Duration > & tp) -> std::cv_status

    Wait for events to occur until specified time tp unlocking lock for the duration of the wait.

  • template <class Lock, class Rep, class Period, class Pred>
    wait_for(Lock & lock, const std::chrono::duration< Rep, Period > & dur, Pred pred) -> bool

    Wait for events to occur specified amount of time dur unlocking lock for the duration of the wait until predicate pred becomes true or timeout occurs.

    • If pred is true upon the call to this method no waiting or unlocking is done
    • The mutex is locked when checking for the predicate.

    Return
    predicate value
  • template <class Lock, class Rep, class Period>
    wait_for(Lock & lock, const std::chrono::duration< Rep, Period > & dur) -> std::cv_status

    Wait for events to occur specified amount of time dur unlocking lock for the duration of the wait.

    bad_call
    if system error occurs, except std::errc::interrupted

    See
    epoll_wait(2)
    See
    std::errc
  • template <class Lock, class Pred>
    wait(Lock & lock, Pred pred) -> void

    Wait for events to occur unlocking lock for the duration of the wait until predicate pred becomes true.

    bad_call
    if system error occurs, except std::errc::interrupted

    • If pred is true upon the call to this method no waiting or unlocking is done
    • The mutex is locked when checking for the predicate.

    See
    epoll_wait(2)
    See
    std::errc
  • template <class Lock>
    wait(Lock & lock) -> void

    Wait for events to occur unlocking lock for the duration of the wait.

  • resize(int new_size) -> void

    Change maximum number of events that the poller handles at a time

  • erase(const epoll_event & ev) -> void

    Remove file descriptor-event mask pair to the poller.

    bad_call

    Equivalent to erase(ev.fd()).

    See
    epoll_ctl(2)
  • erase(fd_type fd) -> void

    Remove file descriptor fd from the poller.

    bad_call

    See
    epoll_ctl(2)
  • replace(epoll_event ev) -> void

    Update event mask for existing file descriptor.

    See
    epoll_ctl(2)
  • emplace(fd_type fd, event ev) -> void

    Construct epoll_event in-place with file descriptor fd and event mask ev and add it to the poller.

    bad_call

    See
    epoll_ctl(2)
  • insert(epoll_event ev) -> void

    Add file descriptor-event mask pair to the poller.

    bad_call

    See
    epoll_ctl(2)
  • end() const -> const_iterator

    Returns iterator to the end of array of events.

  • begin() const -> const_iterator

    Returns iterator to the beginning of array of events.

  • notify_all() -> void

    Notify poller of an external event via pipe_in.

  • notify_one() -> void

    Notify poller of an external event via pipe_in.

  • pipe_in() const -> fd_type

    Returns file descriptor which is used to notify poller of an external event.

  • close() -> void

    Close poller and notification file descriptors. After this operation poller becomes unusable.

  • operator=(event_poller &&) -> event_poller &
  • event_poller(event_poller &&)
  • operator=(const event_poller &) -> event_poller &
  • event_poller(const event_poller &)
  • ~event_poller()
  • event_poller(int maxevents = 4096/sizeof(epoll_event))explicit

    Construct event poller with maxevent number of events.

    bad_call

    See
    epoll_ctl(2)
    See
    epoll_create1(2)