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

Function bthread_id_list_reset2_pthreadsafe

src/bthread/id.cpp:754–776  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

752}
753
754int bthread_id_list_reset2_pthreadsafe(bthread_id_list_t* list,
755 int error_code,
756 const std::string& error_text,
757 pthread_mutex_t* mutex) {
758 if (mutex == NULL) {
759 return EINVAL;
760 }
761 if (list->impl == NULL) {
762 return 0;
763 }
764 bthread_id_list_t tmplist;
765 const int rc = bthread_id_list_init(&tmplist, 0, 0);
766 if (rc != 0) {
767 return rc;
768 }
769 // Swap out the list then reset. The critical section is very small.
770 pthread_mutex_lock(mutex);
771 std::swap(list->impl, tmplist.impl);
772 pthread_mutex_unlock(mutex);
773 const int rc2 = bthread_id_list_reset2(&tmplist, error_code, error_text);
774 bthread_id_list_destroy(&tmplist);
775 return rc2;
776}
777
778int bthread_id_list_reset2_bthreadsafe(bthread_id_list_t* list,
779 int error_code,

Callers 2

OnFailedMethod · 0.85

Calls 6

bthread_id_list_initFunction · 0.85
pthread_mutex_lockFunction · 0.85
pthread_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