Class PollingManager

Class Documentation

class PollingManager

Manager for polling for new emails.

Does the polling for new emails and distributes them to handlers.

Public Types

using HandlerFunction = std::function<void(const struct EmailData&)>

Alias for handler function.

Public Functions

explicit PollingManager(std::shared_ptr<EmailReceiver> receiver, const std::optional<std::chrono::nanoseconds> polling_period)

Constructor.

Parameters:
  • receiver – the email receiver to use for getting emails

  • polling_period – the polling period, or std::optional to use the default value

~PollingManager()
void register_handler(const HandlerFunction &handler)

Register a handler with the manager.

The handler function will be called when there is a new email.

Parameters:

handler – the handler to call with new emails

bool has_started() const

Get status.

Returns:

true if it has been started, false otherwise

void start()

Start manager.

void shutdown()

Shut down manager and internal thread.