wex v24.04.0
Classes | Public Member Functions | List of all members
wex::queue_thread< T > 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/core/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 T). More...
 

Public Member Functions

 queue_thread (event_handler &event_handler_instance, unsigned int timeout_ms=500)
 Constructor.
 
void emplace (std::unique_ptr< T > &event)
 Emplaces event on the queue.
 
bool empty () const
 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 T>
class wex::queue_thread< T >

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 T is the type of event to be processed

Constructor & Destructor Documentation

◆ queue_thread()

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

Constructor.

Parameters
event_handler_instanceevent handler
timeout_mstimeout im milliseconds used

Member Function Documentation

◆ emplace()

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

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).