I am new to atomic variables. I am trying to modify this C++ file to break out the benchmark_rx_rate
function in its own file so I can use it in my project.
The main file has a bunch of std::atomic_ullong type variables for logging which I want to preserve. My ideal situation would be to define some struct of all the std::atomic_ullong I need in a benchmark_rx_rate.h
, initialize it when I need it, and to pass through to my new benchmark_rx_rate function in a benchmark_rx_rate.cpp
file.
On line 573 is where the function gets called, like so:
auto rx_thread = thread_group.create_thread([=, &burst_timer_elapsed]() {
benchmark_rx_rate(usrp,
rx_cpu,
rx_stream,
spb,
random_nsamps,
start_time,
burst_timer_elapsed,
elevate_priority,
rx_delay);
});
I am starting small just trying to pass through the num_overruns
variable which is a std::atomic_ullong
. I have tried what was suggested here. I am now getting an error saying:
use of deleted function βstd::atomic<long unsigned int>::atomic(const std::atomic<long unsigned int>&)
What is the best practice for providing am atomic variable to a function that will modify it, if the function is called through a lambda? How would the process differ from passing just a single atomic variable versus passing a struct of atomic variables?