MCPcopy Create free account
hub / github.com/alibaba/PhotonLibOS / timestamp_updater_init

Function timestamp_updater_init

thread/thread.cpp:1224–1239  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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;

Callers 1

TESTFunction · 0.85

Calls 5

update_nowFunction · 0.85
threadClass · 0.70
usleepFunction · 0.70
detachMethod · 0.45
loadMethod · 0.45

Tested by 1

TESTFunction · 0.68