A service that uses a periodic background worker to perform its work. More...
#include <PeriodicService.h>
Protected Member Functions | |
virtual void | MailboxWasConnected () noexceptoverride |
Called when the mailbox is attached to an already running endpoint or if the attached endpoint has just started. More... | |
virtual void | MailboxWillBeDisconnected () noexceptoverride |
Called right before the mailbox is disconnected from its endpoint or if the attached endpoint is about to stop. More... | |
PeriodicService (Endpoint *endpoint, std::chrono::milliseconds period) | |
Construct a new Periodic Service object. More... | |
virtual void | Update ()=0 |
Called periodically to perform work. More... | |
Protected Member Functions inherited from swarmio::Mailbox | |
void | FinishConstruction () |
Called when the last constructor has finished its job. More... | |
void | FinishMovingTo (Mailbox *other) |
Called when message handling should be passed onto the new instance. More... | |
Mailbox () | |
Construct a disconnected Mailbox. More... | |
Mailbox (Endpoint *endpoint) | |
Construct a new Mailbox object. More... | |
Mailbox (Mailbox &&other) | |
Move a Mailbox object. More... | |
Private Member Functions | |
void | Worker () |
Worker thread entry point. More... | |
Private Attributes | |
std::chrono::milliseconds | _period |
Tick period. More... | |
std::atomic< bool > | _shutdownRequested |
Worker thread shutdown requested. More... | |
std::thread * | _worker = nullptr |
Worker thread. More... | |
Additional Inherited Members | |
Public Member Functions inherited from swarmio::Mailbox | |
virtual void | Disconnect () |
Disconnect this Mailbox from the Endpoint. More... | |
Endpoint * | GetEndpoint () |
Get the associated Endpoint. More... | |
Mailbox (const Mailbox &)=delete | |
Remove copy constructor. More... | |
virtual void | NodeDidJoin (const Node *node) noexcept |
Called when a new Node has joined the group. More... | |
virtual void | NodeWasDiscovered (const Node *node) noexcept |
Called when a new Node has been discovered. More... | |
virtual void | NodeWillLeave (const Node *node) noexcept |
Called when a Node signals that it will leave. More... | |
Mailbox & | operator= (const Mailbox &)=delete |
Remove assignment operator. More... | |
virtual bool | ReceiveMessage (const Node *sender, const data::Message *message) |
Delivery point of all messages. More... | |
virtual | ~Mailbox () |
Destroy the Mailbox object. More... | |
A service that uses a periodic background worker to perform its work.
Definition at line 13 of file PeriodicService.h.
|
inlineprotected |
Construct a new Periodic Service object.
endpoint | Endpoint |
period | Background worker period |
Definition at line 49 of file PeriodicService.h.
|
overrideprotectedvirtualnoexcept |
Called when the mailbox is attached to an already running endpoint or if the attached endpoint has just started.
Reimplemented from swarmio::Mailbox.
Definition at line 30 of file PeriodicService.cpp.
|
overrideprotectedvirtualnoexcept |
Called right before the mailbox is disconnected from its endpoint or if the attached endpoint is about to stop.
Reimplemented from swarmio::Mailbox.
Definition at line 36 of file PeriodicService.cpp.
|
protectedpure virtual |
Called periodically to perform work.
Implemented in swarmio::services::telemetry::Service.
|
private |
Worker thread entry point.
Definition at line 6 of file PeriodicService.cpp.
|
private |
Tick period.
Definition at line 33 of file PeriodicService.h.
|
private |
Worker thread shutdown requested.
Definition at line 27 of file PeriodicService.h.
|
private |
Worker thread.
Definition at line 21 of file PeriodicService.h.