R-Type  2
Doom but in better
Loading...
Searching...
No Matches
Queue Class Reference

A thread-safe queue for storing and managing GameMessage objects. More...

#include <Queue.hpp>

Collaboration diagram for Queue:
Collaboration graph

Public Member Functions

void push (const GameMessage &item)
 Push a GameMessage item into the queue.
 
std::optional< GameMessagepop ()
 Try to pop a GameMessage item from the queue.
 
GameMessage waitAndPop ()
 Wait and pop a GameMessage item from the queue. This blocks until an item is available.
 
bool isEmpty ()
 Check if the queue is empty.
 

Detailed Description

A thread-safe queue for storing and managing GameMessage objects.

This class provides thread-safe methods for adding, retrieving, and waiting for GameMessage objects. It uses a mutex and condition variable to ensure synchronization between threads.

Definition at line 17 of file Queue.hpp.

Member Function Documentation

◆ isEmpty()

bool Queue::isEmpty ( )

Check if the queue is empty.

Returns
True if the queue is empty, otherwise false.

Definition at line 25 of file Queue.cpp.

◆ pop()

std::optional< GameMessage > Queue::pop ( )

Try to pop a GameMessage item from the queue.

Returns
An optional containing the GameMessage if the queue is not empty, or std::nullopt otherwise.

Definition at line 9 of file Queue.cpp.

◆ push()

void Queue::push ( const GameMessage & item)

Push a GameMessage item into the queue.

Parameters
itemThe GameMessage to push into the queue.

Definition at line 3 of file Queue.cpp.

◆ waitAndPop()

GameMessage Queue::waitAndPop ( )

Wait and pop a GameMessage item from the queue. This blocks until an item is available.

Returns
The GameMessage item from the queue.

Definition at line 17 of file Queue.cpp.


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