Commit ceabba5d authored by Thomas Braun's avatar Thomas Braun
Browse files

clang-tidy: Fix modernize-use-scoped-lock

Done via

run-clang-tidy-21 -p build/clang-tidy -fix -header-filter='.*' -checks='-*,modernize-use-scoped-lock' 'src' 'log4tango/src/*.cpp' 'tests/catch2/utils/*'

and added missing mutex includes.
parent 8e47c641
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -17,6 +17,8 @@
#include <tango/common/utils/assert.h>
#include <tango/server/Util.h>

#include <mutex>

namespace Tango::telemetry
{

@@ -326,7 +328,7 @@ void InterfaceImplementation::cleanup_tracer_provider() noexcept

void InterfaceImplementation::init_global_propagator() noexcept
{
    const std::lock_guard<std::mutex> lock(InterfaceImplementation::global_propagator_initialized_mutex);
    const std::scoped_lock lock(InterfaceImplementation::global_propagator_initialized_mutex);

    // no mutex need cause devices are created sequentially at startup and the first device is created
    // there's no more danger to have a race condition on the global_propagator_initialized
@@ -852,7 +854,7 @@ void Interface::get_trace_context(std::string &trace_parent, std::string &trace_
//-----------------------------------------------------------------------------------------
Tango::telemetry::InterfacePtr Interface::get_default_interface()
{
    const std::lock_guard<std::mutex> lock(InterfaceImplementation::default_telemetry_interface_mutex);
    const std::scoped_lock lock(InterfaceImplementation::default_telemetry_interface_mutex);

    if(!InterfaceImplementation::default_telemetry_interface)
    {
+2 −2
Original line number Diff line number Diff line
@@ -19,7 +19,7 @@ struct DoubleBuffer
    {
        RingBuffer<T> *buffer = nullptr;
        {
            std::lock_guard<std::mutex> lg{lock};
            std::scoped_lock lg{lock};
            if(enabled)
            {
                std::swap(front, back);
@@ -40,7 +40,7 @@ struct DoubleBuffer

    void enable(bool v)
    {
        std::lock_guard<std::mutex> lg{lock};
        std::scoped_lock lg{lock};
        enabled = v;
        if(v)
        {
+2 −1
Original line number Diff line number Diff line
@@ -9,6 +9,7 @@
#include <condition_variable>
#include <deque>
#include <memory>
#include <mutex>

namespace Tango
{
@@ -23,7 +24,7 @@ class SynchronisedQueue
    void put(T value)
    {
        {
            std::lock_guard<std::mutex> lock{mutex};
            std::scoped_lock lock{mutex};
            values.push_back(value);
        }
        cv.notify_one();