MCPcopy Create free account
hub / github.com/apache/brpc / thread_key_delete

Function thread_key_delete

src/butil/thread_key.cpp:108–131  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

106}
107
108int thread_key_delete(ThreadKey& thread_key) {
109 if (BAIDU_UNLIKELY(!thread_key.Valid())) {
110 return EINVAL;
111 }
112
113 BAIDU_SCOPED_LOCK(g_thread_key_mutex);
114 size_t id = thread_key._id;
115 size_t seq = thread_key._seq;
116 if (id >= g_thread_keys->size() ||
117 seq != (*g_thread_keys)[id].seq ||
118 KEY_UNUSED((*g_thread_keys)[id].seq)) {
119 thread_key.Reset();
120 return EINVAL;
121 }
122
123 ++((*g_thread_keys)[id].seq);
124 // Collect the usable key id for reuse.
125 if (KEY_USABLE((*g_thread_keys)[id].seq)) {
126 g_free_ids->push_back(id);
127 }
128 thread_key.Reset();
129
130 return 0;
131}
132
133int thread_setspecific(ThreadKey& thread_key, void* data) {
134 if (BAIDU_UNLIKELY(!thread_key.Valid())) {

Callers 4

TESTFunction · 0.85
ThreadKeyPerfTestFunction · 0.85
~ThreadLocalMethod · 0.85

Calls 4

ValidMethod · 0.80
sizeMethod · 0.45
ResetMethod · 0.45
push_backMethod · 0.45

Tested by 3

TESTFunction · 0.68
ThreadKeyPerfTestFunction · 0.68