Skip to content

Commit 306e84a

Browse files
committed
Rename atomic_wait functions to atomic_wait_value_equal
Updated the function names from `atomic_wait_value`, `atomic_wait_value_for`, and `atomic_wait_value_until` to `atomic_wait_value_equal`, `atomic_wait_value_equal_for`, and `atomic_wait_value_equal_until` respectively. This change clarifies the function's purpose and improves readability.
1 parent 42bcda1 commit 306e84a

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

include/daw/daw_atomic_wait.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -286,9 +286,9 @@ namespace daw {
286286
* @param order The memory order to use. Defaults to
287287
* `std::memory_order_acquire`.
288288
*/
289-
void
290-
atomic_wait_value( std::atomic<T> const *object, T const &desired_value,
291-
std::memory_order order = std::memory_order_acquire ) {
289+
void atomic_wait_value_equal(
290+
std::atomic<T> const *object, T const &desired_value,
291+
std::memory_order order = std::memory_order_acquire ) {
292292
atomic_wait_if(
293293
object,
294294
[&desired_value]( T const &current_value ) {
@@ -320,10 +320,10 @@ namespace daw {
320320
* or a timeout occurred.
321321
*/
322322
template<typename T, typename Rep, typename Period>
323-
[[nodiscard]] wait_status
324-
atomic_wait_value_for( std::atomic<T> const *object, T const &desired_value,
325-
std::chrono::duration<Rep, Period> const &rel_time,
326-
std::memory_order order = std::memory_order_acquire ) {
323+
[[nodiscard]] wait_status atomic_wait_value_equal_for(
324+
std::atomic<T> const *object, T const &desired_value,
325+
std::chrono::duration<Rep, Period> const &rel_time,
326+
std::memory_order order = std::memory_order_acquire ) {
327327
return atomic_wait_if_for(
328328
object,
329329
[&desired_value]( T const &current_value ) {
@@ -355,7 +355,7 @@ namespace daw {
355355
* or a timeout occurred.
356356
*/
357357
template<typename T, typename Clock, typename Duration>
358-
[[nodiscard]] wait_status atomic_wait_value_until(
358+
[[nodiscard]] wait_status atomic_wait_value_equal_until(
359359
std::atomic<T> const *object, T const &desired_value,
360360
std::chrono::time_point<Clock, Duration> const &timeout_time,
361361
std::memory_order order = std::memory_order_acquire ) {

tests/daw_atomic_wait_test.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ using namespace std::chrono_literals;
1818

1919
DAW_ATTRIB_NOINLINE void test_atomic_wait_value_until_timeout( ) {
2020
auto value = std::atomic<int>{ };
21-
auto result = daw::atomic_wait_value_until(
21+
auto result = daw::atomic_wait_value_equal_until(
2222
&value, 42, std::chrono::system_clock::now( ) + 30ms );
2323
daw_ensure( result == daw::wait_status::timeout );
2424
daw_ensure( value == 0 );
@@ -32,7 +32,7 @@ DAW_ATTRIB_NOINLINE void test_atomic_wait_value_until_no_timeout( ) {
3232
value = 42;
3333
std::atomic_notify_one( &value );
3434
} );
35-
auto const result = daw::atomic_wait_value_until(
35+
auto const result = daw::atomic_wait_value_equal_until(
3636
&value, 42, std::chrono::system_clock::now( ) + 1min );
3737
th.join( );
3838
daw_ensure( result == daw::wait_status::found );
@@ -41,7 +41,7 @@ DAW_ATTRIB_NOINLINE void test_atomic_wait_value_until_no_timeout( ) {
4141

4242
DAW_ATTRIB_NOINLINE void test_atomic_wait_value_for_timeout( ) {
4343
auto value = std::atomic<int>{ };
44-
auto result = daw::atomic_wait_value_for( &value, 42, 30ms );
44+
auto result = daw::atomic_wait_value_equal_for( &value, 42, 30ms );
4545
daw_ensure( result == daw::wait_status::timeout );
4646
daw_ensure( value == 0 );
4747
}
@@ -54,15 +54,15 @@ DAW_ATTRIB_NOINLINE void test_atomic_wait_value_for_no_timeout( ) {
5454
value = 42;
5555
std::atomic_notify_one( &value );
5656
} );
57-
auto const result = daw::atomic_wait_value_for( &value, 42, 1min );
57+
auto const result = daw::atomic_wait_value_equal_for( &value, 42, 1min );
5858
th.join( );
5959
daw_ensure( result == daw::wait_status::found );
6060
daw_ensure( value == 42 );
6161
}
6262

6363
DAW_ATTRIB_NOINLINE void test_atomic_wait_value_already_set( ) {
6464
auto value = std::atomic<int>{ 42 };
65-
daw::atomic_wait_value( &value, 42 );
65+
daw::atomic_wait_value_equal( &value, 42 );
6666
daw_ensure( value == 42 );
6767
}
6868

@@ -75,7 +75,7 @@ DAW_ATTRIB_NOINLINE void test_atomic_wait_value( ) {
7575
};
7676
auto ths = std::array<std::thread, 4>{ std::thread( fn ), std::thread( fn ),
7777
std::thread( fn ), std::thread( fn ) };
78-
daw::atomic_wait_value( &value, 0 );
78+
daw::atomic_wait_value_equal( &value, 0 );
7979
for( auto &th : ths ) {
8080
th.join( );
8181
}

0 commit comments

Comments
 (0)