Zappy GUI
C++ graphic client: renderer, camera, network
Loading...
Searching...
No Matches
EventQueue Class Reference

Thread-safe queue for storing events received from the server. Allows for potential multi-threaded behavior between GUI layers. Not strictly necessary, good to have, future proof. More...

#include <EventQueue.hpp>

+ Collaboration diagram for EventQueue:

Public Member Functions

void push (Event event)
 Pushes an event to the queue. Thread safe.
 
std::optional< Eventpop ()
 Pops an event from the queue. Thread safe.
 
void clear ()
 Clears all pending events from the queue. Thread safe.
 

Private Attributes

std::queue< Event_queue
 
std::mutex _mutex
 

Detailed Description

Thread-safe queue for storing events received from the server. Allows for potential multi-threaded behavior between GUI layers. Not strictly necessary, good to have, future proof.

Definition at line 14 of file EventQueue.hpp.

Member Function Documentation

◆ clear()

void EventQueue::clear ( )

Clears all pending events from the queue. Thread safe.

Definition at line 19 of file EventQueue.cpp.

References _mutex, and _queue.

Referenced by App::run().

+ Here is the caller graph for this function:

◆ pop()

std::optional< Event > EventQueue::pop ( )

Pops an event from the queue. Thread safe.

Returns
An optional containing the popped event, or std::nullopt if the queue is empty.

Definition at line 9 of file EventQueue.cpp.

References _mutex, and _queue.

Referenced by App::run().

+ Here is the caller graph for this function:

◆ push()

void EventQueue::push ( Event  event)

Pushes an event to the queue. Thread safe.

Parameters
eventThe event to push.

Definition at line 3 of file EventQueue.cpp.

References _mutex, and _queue.

Referenced by App::pollAndEnqueue().

+ Here is the caller graph for this function:

Member Data Documentation

◆ _mutex

std::mutex EventQueue::_mutex
private

Definition at line 38 of file EventQueue.hpp.

Referenced by clear(), pop(), and push().

◆ _queue

std::queue<Event> EventQueue::_queue
private

Definition at line 37 of file EventQueue.hpp.

Referenced by clear(), pop(), and push().


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