wex  v21.04.0
Classes | Public Member Functions | List of all members
wex::queue_thread< E > Class Template Reference

This class offers a templatized queue you can put events in, and a thread pool that retrieves the events and publishes them through the event handler. More...

#include <wex/queue-thread.h>

Classes

class  event_handler
 This event handler class must be subclassed and passed in to the queue thread constructor (in order to process events of type E). More...
 

Public Member Functions

 queue_thread (event_handler &event_handler_instance, unsigned int timeout_ms=500)
 Constructor. More...
 
virtual ~queue_thread ()
 Destructor.
 
void emplace (std::unique_ptr< E > &event)
 Emplaces event on the queue. More...
 
bool empty ()
 Returns true if queue is empty.
 
bool is_running () const
 Returns true if event loop is started.
 
void stop ()
 Stops the threads (and processing of events).
 

Detailed Description

template<typename E>
class wex::queue_thread< E >

This class offers a templatized queue you can put events in, and a thread pool that retrieves the events and publishes them through the event handler.

Type E is the type of event to be processed

Constructor & Destructor Documentation

◆ queue_thread()

template<typename E >
wex::queue_thread< E >::queue_thread ( event_handler event_handler_instance,
unsigned int  timeout_ms = 500 
)
inline

Constructor.

Parameters
event_handler_instanceevent handler
timeout_mstimeout im milliseconds used

Member Function Documentation

◆ emplace()

template<typename E >
void wex::queue_thread< E >::emplace ( std::unique_ptr< E > &  event)
inline

Emplaces event on the queue.

The thread pool takes care of reading and clearing the queue, and sending it to the event handler (be sure you have invoked start).