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

Function thread_key_create

thread/thread-key.cpp:60–72  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

58static thread_key_struct thread_keys[THREAD_KEYS_MAX] = {};
59
60int thread_key_create(thread_key_t* key, void (* destr)(void*)) {
61 for (uint64_t index = 0; index < THREAD_KEYS_MAX; ++index) {
62 /* Find a slot in thread_keys which is unused. */
63 uint64_t seq = thread_keys[index].seq;
64 if (key_unused(seq) && key_usable(seq) &&
65 __sync_bool_compare_and_swap(&thread_keys[index].seq, seq, seq + 1)) {
66 thread_keys[index].dtor = destr;
67 *key = index;
68 return 0;
69 }
70 }
71 return EAGAIN;
72}
73
74void* thread_getspecific(thread_key_t key) {
75 auto tls = (thread_local_storage*) (((partial_thread*) CURRENT)->tls);

Callers 5

thread_local_ptrMethod · 0.85
thread_local_ptrMethod · 0.85
st_key_createFunction · 0.85
TESTFunction · 0.85
mainFunction · 0.85

Calls 2

key_unusedFunction · 0.85
key_usableFunction · 0.85

Tested by 2

TESTFunction · 0.68
mainFunction · 0.68