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

Function bthread_key_delete

src/bthread/key.cpp:603–619  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

601}
602
603int bthread_key_delete(bthread_key_t key) {
604 if (key.index < bthread::KEYS_MAX &&
605 key.version == bthread::s_key_info[key.index].version) {
606 BAIDU_SCOPED_LOCK(bthread::s_key_mutex);
607 if (key.version == bthread::s_key_info[key.index].version) {
608 if (++bthread::s_key_info[key.index].version == 0) {
609 ++bthread::s_key_info[key.index].version;
610 }
611 bthread::s_key_info[key.index].dtor = NULL;
612 bthread::s_key_info[key.index].dtor_args = NULL;
613 bthread::s_free_keys[bthread::nfreekey++] = key.index;
614 return 0;
615 }
616 }
617 CHECK(false) << "bthread_key_delete is called on invalid " << key;
618 return EINVAL;
619}
620
621// NOTE: Can't borrow_keytable in bthread_setspecific, otherwise following
622// memory leak may occur:

Callers 4

~CountersWrapperMethod · 0.85
TESTFunction · 0.85
JoinMethod · 0.85

Calls

no outgoing calls

Tested by 2

~CountersWrapperMethod · 0.68
TESTFunction · 0.68