File tree Expand file tree Collapse file tree 1 file changed +3
-3
lines changed
libc/test/integration/src/pthread Expand file tree Collapse file tree 1 file changed +3
-3
lines changed Original file line number Diff line number Diff line change @@ -242,7 +242,7 @@ static void attributed_initialization_test() {
242
242
struct SharedData {
243
243
pthread_rwlock_t lock;
244
244
int data;
245
- int reader_count;
245
+ LIBC_NAMESPACE::cpp::Atomic< int > reader_count;
246
246
bool writer_flag;
247
247
LIBC_NAMESPACE::cpp::Atomic<int > total_writer_count;
248
248
};
@@ -266,11 +266,11 @@ static void randomized_thread_operation(SharedData *data) {
266
266
static_cast <Operation>(buffer % static_cast <int >(Operation::COUNT));
267
267
auto read_ops = [data]() {
268
268
ASSERT_FALSE (data->writer_flag );
269
- ++ data->reader_count ;
269
+ data->reader_count . fetch_add ( 1 , LIBC_NAMESPACE::cpp::MemoryOrder::RELAXED) ;
270
270
for (int i = 0 ; i < 10 ; ++i) {
271
271
LIBC_NAMESPACE::sleep_briefly ();
272
272
}
273
- -- data->reader_count ;
273
+ data->reader_count . fetch_sub ( 1 , LIBC_NAMESPACE::cpp::MemoryOrder::RELAXED) ;
274
274
};
275
275
auto write_ops = [data]() {
276
276
ASSERT_FALSE (data->writer_flag );
You can’t perform that action at this time.
0 commit comments