PLCnext API Documentation
22.9.0.33
|
Proxy object for a non-blocking NotificationRegistration More...
#include <NonBlockingNotificationRegistration3.hpp>
Public Types | |
using | payload_type = PayloadType |
using | arguments_type = ArgumentsType |
Protected Types | |
using | ArgumentsBuffer = NonBlockingNotificationRegistration3ArgumentsBuffer< ArgumentsType > |
![]() | |
typedef Loggable< Derived, IsSingleton, IsStaticClass > | LoggableBase |
Friends | |
class | NotificationManager |
Additional Inherited Members | |
![]() | |
Loggable (bool initialize=true) | |
![]() | |
NonBlockingNotificationRegistration3Base (std::unique_ptr< NonBlockingNotificationSendingAdapter > notificationSending) | |
bool | HasImpl () const |
NotificationNameIdType | GetNotificationNameIdInternal () const |
const Future< NotificationIdType > & | GetFutureNotificationId () const |
void | ResetFutureNotificationId () |
void | Register (const String ¬ificationName, const String &senderName, Severity severity, PayloadTypeIdType payloadTypeId) |
void | Unregister () |
void | SendNotificationInternal (const DateTime ×tamp, std::shared_ptr< NonBlockingNotificationRegistration3ArgumentsBufferBase > argumentsBuffer, NonBlockingNotificationRegistration3ArgumentsBufferBase::InsertResult argumentsBufferInsertResult, NonBlockingNotificationSendingAdapter::CreatePayloadFunctor createPayloadFunctor) |
bool | IsReadyToSend () const |
![]() | |
static void | InitializeLogger (const char *loggerName=nullptr) |
![]() | |
static Logger< Derived > | log |
Proxy object for a non-blocking NotificationRegistration
This proxy class represents a Notification registration like a smart pointer. The Notification is registered in the constructor and unregistered in the destructor. Notifications can be send using the SendNotification method. The template parameter PayloadType indicates the Payload class to be used when sending Notifications.
This class supports move semantics. Ownership of a notification registration is transfered by a move operation.
Use NotificationManager::CreateNonBlockingNotificationRegistration3 to create instances of this type.
This class does not allocate memory to send notifications. This is required to use it in real-time context. When SendNotification is called a request to send a notification is inserted into a queue. A worker thread will send the notification later. Creating payload objects is expensive. Therefore they are created by the worker thread. The arguments to create the payload object (type ArgumentsType) are stored in a buffer until the payload object is created. ArgumentsType shall be small and shall not allocate dynamic memory.
The PayloadType must have a constructor with exactly one parameter of ArgumentsType. This will be called to construct the payload object.
Sending strings as payload is supported. Since Arp::String and std::string allocate memory on the heap the strings shall be passed as const char* via ArgumentsType. The pointers must stay valid until the worker thread has constructed the payload object. Use IsCompleted() to check whether the last SendNotification call has been processed by the worker thread. It is recommended to use constant strings or literals.
When a call to SendNotification cannot be executed (e.g. too many entries in the queue of the worker thread or in the buffer for ArgumentsType) an invalid Future<NotificationIdType> is returned. Use IsValid() to check it. If the future is invalid, wait for the worker thread to process some requests and try again later.
|
default |
Creates an empty NotificationRegistration
To be used as a class member, when it cannot be initialized directly. Use move semantics to transfer ownership from another object.
|
overridevirtual |
Returns the NotificationNameId
Future< NotificationIdType > Arp::System::Nm::NonBlockingNotificationRegistration3< PayloadType, ArgumentsType >::SendNotification | ( | Args &&... | args | ) |
Sends a notification
args | Arguments to the constructor of PayloadType (variadic) |
Uses the current time as timestamp.
Future< NotificationIdType > Arp::System::Nm::NonBlockingNotificationRegistration3< PayloadType, ArgumentsType >::SendNotificationWithTimestamp | ( | const DateTime & | timestamp, |
Args &&... | args | ||
) |
Sends a notification with a specified timestamp
timestamp | timestamp to be used |
args | Arguments to the constructor of PayloadType (variadic) |