Class EventSignalHandle

Class Documentation

class EventSignalHandle

The EventSignalHandle class represents a signal in the event loop.

An EventSignalHandle is created by calling create_signal. It offers an interface to fire the signal and acts as an RAII handle to the signal. When the handle is destroyed, the signal is removed from the event loop.

The event loop does guarantee that outstanding events are handled up to a timeout even if the signal is removed.

Public Functions

explicit EventSignalHandle(int fd, const std::shared_ptr<BaseEventLoop> &evloop)

Construct a new EventSignalHandle object.

Not supposed to be called directly. Use create_signal instead.

Parameters:
  • fd – The file descriptor of the signal

  • evloop – The event loop to register the signal with

~EventSignalHandle()

Destroy the EventSignalHandle object.

If this is the last reference to the signal, the signal is removed from the event loop.

EventSignalHandle(const EventSignalHandle&) = default
EventSignalHandle(EventSignalHandle&&) = default
EventSignalHandle &operator=(const EventSignalHandle&) = default
EventSignalHandle &operator=(EventSignalHandle&&) = default
void fire() const

Fires the signal.

Writes a byte to the file descriptor of the signal. If the write fails, an error is issued.

inline int get_fd() const

Get the file descriptor of the signal.

Returns:

The file descriptor of the signal