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

Function thread_local_data

src/brpc/server.cpp:1883–1901  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1881}
1882
1883void* thread_local_data() {
1884 const Server::ThreadLocalOptions* tl_options =
1885 static_cast<const Server::ThreadLocalOptions*>(bthread_get_assigned_data());
1886 if (tl_options == NULL) { // not in server threads.
1887 return NULL;
1888 }
1889 if (BAIDU_UNLIKELY(tl_options->thread_local_data_factory == NULL)) {
1890 CHECK(false) << "The protocol impl. may not set tls correctly";
1891 return NULL;
1892 }
1893 void* data = bthread_getspecific(tl_options->tls_key);
1894 if (data == NULL) {
1895 data = tl_options->thread_local_data_factory->CreateData();
1896 if (data != NULL) {
1897 CHECK_EQ(0, bthread_setspecific(tl_options->tls_key, data));
1898 }
1899 }
1900 return data;
1901}
1902
1903inline void tabs_li(std::ostream& os, const char* link,
1904 const char* tab_name, const char* current_tab_name) {

Callers 1

EchoMethod · 0.85

Calls 4

bthread_getspecificFunction · 0.85
bthread_setspecificFunction · 0.85
CreateDataMethod · 0.45

Tested by

no test coverage detected