MPD 0.20.6

- Main Page
- Namespaces
- Data Structures
- Files

- Data Structures
- Class Hierarchy
- Data Fields

Data Structures | Public Member Functions
EventLoop Class Referencefinal

An event loop that polls for events on file/socket descriptors. More...

`#include <Loop.hxx>`

Inheritance diagram for EventLoop:
[legend]
Collaboration diagram for EventLoop:
[legend]

## Public Member Functions
| EventLoop ()
| ~EventLoop ()
std::chrono::steady_clock::time_point | GetTime () const
| A caching wrapper for std::chrono::steady_clock::now(). More...
void | Break ()
| Stop execution of this EventLoop at the next chance. More...
bool | AddFD (int _fd, unsigned flags, SocketMonitor &m)
bool | ModifyFD (int _fd, unsigned flags, SocketMonitor &m)
bool | Abandon (int fd, SocketMonitor &m)
| Remove the given SocketMonitor after the file descriptor has been closed. More...
bool | RemoveFD (int fd, SocketMonitor &m)
void | AddIdle (IdleMonitor &i)
void | RemoveIdle (IdleMonitor &i)
void | AddTimer (TimeoutMonitor &t, std::chrono::steady_clock::duration d)
void | CancelTimer (TimeoutMonitor &t)
void | AddDeferred (DeferredMonitor &d)
| Schedule a call to DeferredMonitor::RunDeferred(). More...
void | RemoveDeferred (DeferredMonitor &d)
| Cancel a pending call to DeferredMonitor::RunDeferred(). More...
void | Run ()
| The main function of this class. More...
gcc_pure bool | IsInside () const
| Are we currently running inside this EventLoop's thread? More...
gcc_pure bool | IsInsideOrVirgin () const
gcc_pure bool | IsInsideOrNull () const
| Like IsInside(), but also returns true if the thread has already ended (or was not started yet). More...

## Detailed Description

An event loop that polls for events on file/socket descriptors.

This class is not thread-safe, all methods must be called from the thread that runs it, except where explicitly documented as thread-safe.

See also
  SocketMonitor, MultiSocketMonitor, TimeoutMonitor, IdleMonitor

Definition at line 51 of file Loop.hxx.

## Constructor & Destructor Documentation

EventLoop::EventLoop | ( |  | ) |

EventLoop::~EventLoop | ( |  | ) |

## Member Function Documentation

bool EventLoop::Abandon | ( | int | fd,
|  | SocketMonitor & | m
| ) |  |

Remove the given SocketMonitor after the file descriptor has been closed.

This is like RemoveFD(), but does not attempt to use #EPOLL_CTL_DEL.

void EventLoop::AddDeferred | ( | DeferredMonitor & | d | ) |

Schedule a call to DeferredMonitor::RunDeferred().

This method is thread-safe.

bool EventLoop::AddFD | ( | int | _fd,
|  | unsigned | flags,
|  | SocketMonitor & | m
| ) |  |
| inline

Definition at line 137 of file Loop.hxx.

void EventLoop::AddIdle | ( | IdleMonitor & | i | ) |

void EventLoop::AddTimer | ( | TimeoutMonitor & | t,
|  | std::chrono::steady_clock::duration | d
| ) |  |

void EventLoop::Break | ( |  | ) |

Stop execution of this EventLoop at the next chance.

This method is thread-safe and non-blocking: after returning, it is not guaranteed that the EventLoop has really stopped.

void EventLoop::CancelTimer | ( | TimeoutMonitor & | t | ) |

std::chrono::steady_clock::time_point EventLoop::GetTime | ( |  | ) | const
| inline

A caching wrapper for std::chrono::steady_clock::now().

Definition at line 124 of file Loop.hxx.

gcc_pure bool EventLoop::IsInside | ( |  | ) | const
| inline

Are we currently running inside this EventLoop's thread?

Definition at line 202 of file Loop.hxx.

gcc_pure bool EventLoop::IsInsideOrNull | ( |  | ) | const
| inline

Like IsInside(), but also returns true if the thread has already ended (or was not started yet).

This is useful for code which may run during startup or shutdown, when events are not yet/anymore handled.

Definition at line 222 of file Loop.hxx.

gcc_pure bool EventLoop::IsInsideOrVirgin | ( |  | ) | const
| inline

Definition at line 210 of file Loop.hxx.

bool EventLoop::ModifyFD | ( | int | _fd,
|  | unsigned | flags,
|  | SocketMonitor & | m
| ) |  |
| inline

Definition at line 143 of file Loop.hxx.

void EventLoop::RemoveDeferred | ( | DeferredMonitor & | d | ) |

Cancel a pending call to DeferredMonitor::RunDeferred().

However after returning, the call may still be running.

This method is thread-safe.

bool EventLoop::RemoveFD | ( | int | fd,
|  | SocketMonitor & | m
| ) |  |

void EventLoop::RemoveIdle | ( | IdleMonitor & | i | ) |

void EventLoop::Run | ( |  | ) |

The main function of this class.

It will loop until Break() gets called. Can be called only once.

The documentation for this class was generated from the following file:

- event/Loop.hxx