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

Function bthread_id_list_reset2_bthreadsafe

src/bthread/id.cpp:778–800  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

776}
777
778int bthread_id_list_reset2_bthreadsafe(bthread_id_list_t* list,
779 int error_code,
780 const std::string& error_text,
781 bthread_mutex_t* mutex) {
782 if (mutex == NULL) {
783 return EINVAL;
784 }
785 if (list->impl == NULL) {
786 return 0;
787 }
788 bthread_id_list_t tmplist;
789 const int rc = bthread_id_list_init(&tmplist, 0, 0);
790 if (rc != 0) {
791 return rc;
792 }
793 // Swap out the list then reset. The critical section is very small.
794 bthread_mutex_lock(mutex);
795 std::swap(list->impl, tmplist.impl);
796 bthread_mutex_unlock(mutex);
797 const int rc2 = bthread_id_list_reset2(&tmplist, error_code, error_text);
798 bthread_id_list_destroy(&tmplist);
799 return rc2;
800}

Callers 1

Calls 6

bthread_id_list_initFunction · 0.85
bthread_mutex_lockFunction · 0.85
bthread_mutex_unlockFunction · 0.85
bthread_id_list_reset2Function · 0.85
bthread_id_list_destroyFunction · 0.85
swapFunction · 0.50

Tested by

no test coverage detected