Veethree D7 SDK
Loading...
Searching...
No Matches
vsdk::io::event_queue Class Reference

Detailed Description

The event_queue class.

This class implements a queue intended for storing vsdk::io::event objects (as std::shared_ptr). You can install multiple handlers for the same event source and type.

Event objects will handled in background as soon as possible once they are added to the queue. Once an event is processed by all its handlers, it is removed from queue.

#include <io_event_queue.h>

Public Member Functions

 event_queue (const event_queue &eq)=delete
 event_queue (event_queue &&eq) noexcept=delete
event_queue & operator= (const event_queue &)=delete
event_queue & operator= (event_queue &&eq) noexcept=delete
event_handler_id add_handler (event_source evt_src, event_type evt_type, event_handler evt_handler)
 Add an event handler for a specific type of event.
bool remove_handler (event_handler_id id)
 Remove an event handler from the event queue.
void remove_all_handlers ()
 Remove all handlers for this queue.
void push_event (std::shared_ptr< event > evt)
 Push an event into the queue.
void flush_events ()
 Flush all events from the queue. Handlers will not be called for existing items in the queue.

Detailed Description

The event_queue class.

This class implements a queue intended for storing vsdk::io::event objects (as std::shared_ptr). You can install multiple handlers for the same event source and type.

Event objects will handled in background as soon as possible once they are added to the queue. Once an event is processed by all its handlers, it is removed from queue.

Member Function Documentation

◆ add_handler()

event_handler_id vsdk::io::event_queue::add_handler ( event_source evt_src,
event_type evt_type,
event_handler evt_handler )

Add an event handler for a specific type of event.

See also the event_notification interface.

Parameters
evt_srcThe event source. See vsdk::io::event_source.
evt_typeThe event type. See vsdk::io::event_type.
evt_handlerThe event handler. See vsdk::io::event_handler.
Returns
The event handler id, used to remove a handler if required. See vsdk::io::event_handler_id.
#include <libio/i420.h>
using namespace vsdk::io;
void fn()
{
auto q = std::make_shared<event_queue>();
auto const id2 = q->add_handler(io::event_source::i420_vsns,
fn_thr_below);
auto const id3 = q->add_handler(io::event_source::i420_vsns,
fn_in_range);
// the creation of events is via event_notification::add_notification interface
}
@ in_range
any value inside of [start, end) - including start, excluding end.
Definition io_event_common.h:46
@ threshold_below
any value less than the threshold specified.
Definition io_event_common.h:44
i420 interface
IO event queue interface.
IO range event interface.
IO threshold event interface.
Any entities that belong to the IO library.

◆ push_event()

void vsdk::io::event_queue::push_event ( std::shared_ptr< event > evt)

Push an event into the queue.

Parameters
evtA std::shared_ptr<event> object. The object in the std::shared_ptr must implement vsdk::io::event interface.

◆ remove_handler()

bool vsdk::io::event_queue::remove_handler ( event_handler_id id)

Remove an event handler from the event queue.

Parameters
idThe event handler to be removed. See vsdk::io::event_handler_id.
Returns
Return true when the handler has been removed, otherwise false.

The documentation for this class was generated from the following file: