MCPcopy Create free account
hub / github.com/Snapchat/Valdi / startServices

Method startServices

valdi/src/valdi/runtime/Debugger/TCPClient.cpp:171–194  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

169 std::atomic_bool _started = {false};
170
171 Result<Void> startServices() {
172 std::lock_guard<Mutex> lock(_mutex);
173
174 if (_asioThread != nullptr) {
175 return Void();
176 }
177
178 _started = true;
179 // Allow io_service to be reused after a previous stop()
180 _ioService.reset();
181 // Use a work guard to keep run() active until handler returns to
182 // prevent possible deadlock if asio thread exits (eg. error or other thread closure)
183 // and we post and wait indefinitely for the non-existent thread to complete.
184 _work = std::make_shared<boost::asio::io_service::work>(_ioService);
185
186 auto threadResult =
187 Thread::create(STRING_LITERAL("TCP Client"), ThreadQoSClassNormal, [this]() { this->runIOService(); });
188 if (!threadResult) {
189 _work.reset();
190 return threadResult.moveError();
191 }
192 _asioThread = threadResult.moveValue();
193 return Void();
194 }
195
196 void runIOService() {
197 {

Callers

nothing calls this directly

Calls 4

runIOServiceMethod · 0.95
resetMethod · 0.65
VoidClass · 0.50
createFunction · 0.50

Tested by

no test coverage detected