perf: Optimize ATOMIC_READ

This commit is contained in:
luwenpeng
2023-10-13 12:00:39 +08:00
parent 8d1a9b3be5
commit 8f11f8381d
3 changed files with 17 additions and 10 deletions

View File

@@ -41,7 +41,7 @@ void timestamp_update(struct timestamp *ts)
clock_gettime(CLOCK_MONOTONIC, &temp);
uint64_t current_timestamp_ms = temp.tv_sec * 1000 + temp.tv_nsec / 1000000;
__atomic_store_n(&ts->timestamp_ms, current_timestamp_ms, __ATOMIC_RELEASE);
ATOMIC_SET(&ts->timestamp_ms, current_timestamp_ms);
}
uint64_t timestamp_update_interval_ms(struct timestamp *ts)
@@ -51,5 +51,5 @@ uint64_t timestamp_update_interval_ms(struct timestamp *ts)
uint64_t timestamp_get_msec(struct timestamp *ts)
{
return __atomic_load_n(&ts->timestamp_ms, __ATOMIC_ACQUIRE);
return ATOMIC_READ(&ts->timestamp_ms);
}