| 1222 | return update_now(); |
| 1223 | } |
| 1224 | int timestamp_updater_init() { |
| 1225 | if (!ts_updater) { |
| 1226 | std::thread([&]{ |
| 1227 | pthread_t current_tid = pthread_self(), pid = 0; |
| 1228 | if (!ts_updater.compare_exchange_weak(pid, current_tid, std::memory_order_acq_rel)) |
| 1229 | return; |
| 1230 | while (current_tid == ts_updater.load(std::memory_order_relaxed)) { |
| 1231 | usleep(500); |
| 1232 | update_now(); |
| 1233 | } |
| 1234 | }).detach(); |
| 1235 | return 0; |
| 1236 | } |
| 1237 | LOG_WARN("Timestamp updater already started"); |
| 1238 | return -1; |
| 1239 | } |
| 1240 | int timestamp_updater_fini() { |
| 1241 | if (ts_updater.load()) { |
| 1242 | ts_updater = 0; |