MCPcopy Create free account
hub / github.com/async-profiler/async-profiler / drain

Method drain

src/wallClock.cpp:79–98  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

77 }
78
79 void drain(ThreadSleepMap& thread_sleep_state) {
80 u64 read_limit = _read_ptr + RINGBUF_SIZE;
81 do {
82 ThreadCpuTime& t = _ringbuf[_read_ptr & (RINGBUF_SIZE - 1)];
83 u64 cpu_time = loadAcquire(t.cpu_time);
84 if (cpu_time == 0) {
85 break;
86 }
87
88 u64 trace = t.trace;
89 if (__sync_bool_compare_and_swap(&t.cpu_time, cpu_time, 0)) {
90 int thread_id = trace >> 32;
91 ThreadSleepState& tss = thread_sleep_state[thread_id];
92 tss.last_cpu_time = cpu_time;
93 tss.call_trace_id = (u32)trace;
94 tss.counter = 0;
95 _read_ptr++;
96 }
97 } while (_read_ptr < read_limit);
98 }
99};
100
101static ThreadCpuTimeBuffer _thread_cpu_time_buf;

Callers 1

timerLoopMethod · 0.80

Calls 1

loadAcquireFunction · 0.85

Tested by

no test coverage detected