Skip to content

Commit c45b02f

Browse files
konardclaude
andcommitted
style: fix clang-format violations in pam_pmm.h and test_pam_pmm_threadsafe.cpp
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 6303301 commit c45b02f

2 files changed

Lines changed: 22 additions & 20 deletions

File tree

pam_pmm.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ struct pam_pmm_state
181181
char filename[256] = {}; ///< Имя файла хранилища
182182
uintptr_t root_offset = 0; ///< Смещение корневой структуры в ПАП
183183
bool initialized = false; ///< Флаг инициализации
184-
mutable std::mutex mtx; ///< Мьютекс для потокобезопасной инициализации (Этап C)
184+
mutable std::mutex mtx; ///< Мьютекс для потокобезопасной инициализации (Этап C)
185185

186186
/// Сбросить все поля к начальным значениям.
187187
/// @note Вызывающий должен удерживать mtx (или гарантировать эксклюзивный доступ).

tests/test_pam_pmm_threadsafe.cpp

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ using namespace pjson;
2222
TEST_CASE( "pam_pmm_threadsafe: mutex exists in pam_pmm_state", "[pam_pmm][threadsafe]" )
2323
{
2424
// Проверяем, что pam_pmm_state содержит мьютекс (компилируется).
25-
pam_pmm_state state;
25+
pam_pmm_state state;
2626
std::lock_guard<std::mutex> lock( state.mtx );
2727
REQUIRE_FALSE( state.initialized );
2828
}
@@ -32,17 +32,18 @@ TEST_CASE( "pam_pmm_threadsafe: concurrent is_initialized reads", "[pam_pmm][thr
3232
pam_pmm_init( nullptr );
3333
REQUIRE( pam_pmm_is_initialized() );
3434

35-
constexpr int NUM_THREADS = 8;
36-
std::atomic<int> success_count{ 0 };
35+
constexpr int NUM_THREADS = 8;
36+
std::atomic<int> success_count{ 0 };
3737
std::vector<std::thread> threads;
3838

3939
for ( int i = 0; i < NUM_THREADS; ++i )
4040
{
41-
threads.emplace_back( [&success_count]()
42-
{
43-
if ( pam_pmm_is_initialized() )
44-
success_count.fetch_add( 1 );
45-
} );
41+
threads.emplace_back(
42+
[&success_count]()
43+
{
44+
if ( pam_pmm_is_initialized() )
45+
success_count.fetch_add( 1 );
46+
} );
4647
}
4748

4849
for ( auto& t : threads )
@@ -73,7 +74,7 @@ TEST_CASE( "pam_pmm_threadsafe: concurrent init/destroy with explicit state", "[
7374
// одновременный доступ к одному и тому же state из разных потоков.
7475
pam_pmm_state state;
7576

76-
constexpr int ITERATIONS = 5;
77+
constexpr int ITERATIONS = 5;
7778
constexpr int NUM_THREADS = 4;
7879

7980
for ( int iter = 0; iter < ITERATIONS; ++iter )
@@ -83,18 +84,19 @@ TEST_CASE( "pam_pmm_threadsafe: concurrent init/destroy with explicit state", "[
8384
REQUIRE( pam_pmm_is_initialized( state ) );
8485

8586
// Несколько потоков одновременно проверяют состояние.
86-
std::atomic<int> check_count{ 0 };
87+
std::atomic<int> check_count{ 0 };
8788
std::vector<std::thread> threads;
8889

8990
for ( int i = 0; i < NUM_THREADS; ++i )
9091
{
91-
threads.emplace_back( [&state, &check_count]()
92-
{
93-
// Каждый поток проверяет is_initialized через мьютекс.
94-
bool ok = pam_pmm_is_initialized( state );
95-
if ( ok )
96-
check_count.fetch_add( 1 );
97-
} );
92+
threads.emplace_back(
93+
[&state, &check_count]()
94+
{
95+
// Каждый поток проверяет is_initialized через мьютекс.
96+
bool ok = pam_pmm_is_initialized( state );
97+
if ( ok )
98+
check_count.fetch_add( 1 );
99+
} );
98100
}
99101

100102
for ( auto& t : threads )
@@ -113,8 +115,8 @@ TEST_CASE( "pam_pmm_threadsafe: reset is serialized", "[pam_pmm][threadsafe]" )
113115
pam_pmm_init( nullptr );
114116

115117
// Создаём объект.
116-
auto& state = pam_pmm_global_state();
117-
uintptr_t off = pam_pmm_create<int>( state, "test_threadsafe" );
118+
auto& state = pam_pmm_global_state();
119+
uintptr_t off = pam_pmm_create<int>( state, "test_threadsafe" );
118120
REQUIRE( off != 0 );
119121

120122
// Reset через мьютекс.

0 commit comments

Comments
 (0)