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

Method incrementSampleCounter

src/threadLocalData.h:19–26  ·  view source on GitHub ↗

Increment the thread-local sample counter. See the `asprof_thread_local_data` docs. This function *is* async-signal safe, and therefore will not initialize the thread-local storage by itself, but will rather do nothing if it's not initialized already. This works fine with the `sample_counter` API since only changes in `sample_counter` matter.

Source from the content-addressed store, hash-verified

17 // storage by itself, but will rather do nothing if it's not initialized already. This works
18 // fine with the `sample_counter` API since only changes in `sample_counter` matter.
19 static void incrementSampleCounter(void) {
20 if (_profiler_data_key == -1) return;
21
22 asprof_thread_local_data* data = (asprof_thread_local_data*) pthread_getspecific(_profiler_data_key);
23 if (data != NULL) {
24 data->sample_counter++;
25 }
26 }
27
28 // Get the `asprof_thread_local_data`. See the `asprof_get_thread_local_data` docs.
29 static asprof_thread_local_data* getThreadLocalData(void) {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected