void Client::initThread(const char* desc, ServiceContext* service, transport::SessionHandle session) { invariant(currentClient.getMake()->get() == nullptr); std::string fullDesc; if (session) { fullDesc = str::stream() << desc << session->id(); } else { fullDesc = desc; } setThreadName(fullDesc.c_str()); // Create the client obj, attach to thread *currentClient.get() = service->makeClient(fullDesc, std::move(session)); }
void Client::initThreadIfNotAlready(const char* desc) { if (currentClient.getMake()->get()) return; initThread(desc); }
Client& cc() { Client* c = currentClient.getMake()->get(); invariant(c); return *c; }
bool haveClient() { return currentClient.getMake()->get(); }
Client* Client::getCurrent() { return currentClient.getMake()->get(); }