BCNP 3.2.1
Batched Command Network Protocol
Loading...
Searching...
No Matches
bcnp::MessageQueue< MsgType >::Transaction Class Reference

RAII transaction for atomic batch operations. More...

#include <message_queue.h>

Public Member Functions

 Transaction (MessageQueue &queue)
 
bool Push (const MsgType &message)
 
void Clear ()
 

Detailed Description

template<typename MsgType>
class bcnp::MessageQueue< MsgType >::Transaction

RAII transaction for atomic batch operations.

Holds the queue mutex for the lifetime of the transaction, allowing multiple Push() or Clear() calls without interleaving.

{
auto tx = queue.BeginTransaction();
tx.Clear();
for (const auto& cmd : commands) {
tx.Push(cmd);
}
} // Lock released here

Definition at line 274 of file message_queue.h.

Constructor & Destructor Documentation

◆ Transaction()

template<typename MsgType >
bcnp::MessageQueue< MsgType >::Transaction::Transaction ( MessageQueue & queue)
inlineexplicit

Definition at line 276 of file message_queue.h.

Member Function Documentation

◆ Clear()

template<typename MsgType >
void bcnp::MessageQueue< MsgType >::Transaction::Clear ( )
inline

Definition at line 288 of file message_queue.h.

◆ Push()

template<typename MsgType >
bool bcnp::MessageQueue< MsgType >::Transaction::Push ( const MsgType & message)
inline

Definition at line 279 of file message_queue.h.


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