Class PollHandle

Synopsis

#include <src/uvw/poll.h>

class PollHandle final: public Handle<PollHandle, uv_poll_t>

Description

The PollHandle handle.

Poll handles are used to watch file descriptors for readability, writability and disconnection.

To create a PollHandle through a Loop, arguments follow:

  • A descriptor that can be:

See the official documentation for further details.

Inheritance

Ancestors: Handle

Methods

PollHandle overload
initInitializes the handle.
start overloadStarts polling the file descriptor.
stopStops polling the file descriptor.

Source

Lines 67-135 in src/uvw/poll.h.

class PollHandle final: public Handle<PollHandle, uv_poll_t> {
    static void startCallback(uv_poll_t *handle, int status, int events);

public:
    using Event = details::UVPollEvent;

    explicit PollHandle(ConstructorAccess ca, std::shared_ptr<Loop> ref, int desc);
    explicit PollHandle(ConstructorAccess ca, std::shared_ptr<Loop> ref, OSSocketHandle sock);

    /**
     * @brief Initializes the handle.
     * @return True in case of success, false otherwise.
     */
    bool init();

    /**
     * @brief Starts polling the file descriptor.
     *
     * Available flags are:
     *
     * * `PollHandle::Event::READABLE`
     * * `PollHandle::Event::WRITABLE`
     * * `PollHandle::Event::DISCONNECT`
     * * `PollHandle::Event::PRIORITIZED`
     *
     * As soon as an event is detected, a PollEvent is emitted by the
     * handle.<br>
     * It could happen that ErrorEvent events are emitted while running.
     *
     * Calling more than once this method will update the flags to which the
     * caller is interested.
     *
     * @param flags The events to which the caller is interested.
     */
    void start(Flags<Event> flags);

    /**
     * @brief Starts polling the file descriptor.
     *
     * Available flags are:
     *
     * * `PollHandle::Event::READABLE`
     * * `PollHandle::Event::WRITABLE`
     * * `PollHandle::Event::DISCONNECT`
     * * `PollHandle::Event::PRIORITIZED`
     *
     * As soon as an event is detected, a PollEvent is emitted by the
     * handle.<br>
     * It could happen that ErrorEvent events are emitted while running.
     *
     * Calling more than once this method will update the flags to which the
     * caller is interested.
     *
     * @param event The event to which the caller is interested.
     */
    void start(Event event);

    /**
     * @brief Stops polling the file descriptor.
     */
    void stop();

private:
    enum { FD, SOCKET } tag;
    union {
        int file_desc;
        OSSocketHandle::Type socket;
    };
};





Add Discussion as Guest

Log in