FERS 1.0.0
The Flexible Extensible Radar Simulator
Loading...
Searching...
No Matches
core::ProgressReporter Class Reference

A thread-safe wrapper for the simulation progress callback. More...

#include "sim_threading.h"

Public Types

using Callback = std::function< void(const std::string &, int, int)>
 Defines the signature for the progress reporting callback function.
 

Public Member Functions

 ProgressReporter (Callback cb)
 Constructs a ProgressReporter with the given callback.
 
void report (const std::string &msg, int current, int total)
 Safely reports progress to the underlying callback.
 

Detailed Description

A thread-safe wrapper for the simulation progress callback.

Allows multiple worker threads to report progress concurrently without race conditions.

Definition at line 56 of file sim_threading.h.

Member Typedef Documentation

◆ Callback

Defines the signature for the progress reporting callback function.

Definition at line 63 of file sim_threading.h.

Constructor & Destructor Documentation

◆ ProgressReporter()

core::ProgressReporter::ProgressReporter ( Callback  cb)
explicit

Constructs a ProgressReporter with the given callback.

Parameters
cbThe callback function to wrap.

Definition at line 69 of file sim_threading.h.

69: _callback(std::move(cb)) {}

Member Function Documentation

◆ report()

void core::ProgressReporter::report ( const std::string &  msg,
int  current,
int  total 
)

Safely reports progress to the underlying callback.

Parameters
msgThe status message to report.
currentThe current progress value.
totalThe total progress value.

Definition at line 77 of file sim_threading.h.

78 {
79 if (_callback)
80 {
81 std::scoped_lock lock(_mutex);
82 _callback(msg, current, total);
83 }
84 }

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