MCPcopy Create free account
hub / github.com/emscripten-core/emscripten / mi_thread_local_claim

Function mi_thread_local_claim

system/lib/mimalloc/src/threadlocal.c:174–184  ·  view source on GitHub ↗

When we claim a free slot, we increase the global version counter (so if we reuse a slot it will be returning NULL initially when a thread tries to get it)

Source from the content-addressed store, hash-verified

172// When we claim a free slot, we increase the global version counter
173// (so if we reuse a slot it will be returning NULL initially when a thread tries to get it)
174static mi_thread_local_t mi_thread_local_claim(void) {
175 size_t idx = 0;
176 if (mi_thread_locals_free != NULL && mi_bitmap_try_find_and_claim(mi_thread_locals_free,0,&idx,&mi_thread_local_claim_fun,NULL)) {
177 mi_thread_locals_version++;
178 if (mi_thread_locals_version == SIZE_MAX/2) { mi_thread_locals_version = 1; }
179 return mi_key_create( idx, mi_thread_locals_version);
180 }
181 else {
182 return 0;
183 }
184}
185
186static bool mi_thread_local_create_expand(void) {
187 mi_bitmap_t* slots = mi_thread_locals_free;

Callers 1

_mi_thread_local_createFunction · 0.85

Calls 2

mi_key_createFunction · 0.85

Tested by

no test coverage detected