MCPcopy Create free account
hub / github.com/TactilityProject/Tactility / stopService

Function stopService

Tactility/Source/service/ServiceRegistration.cpp:104–127  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

102}
103
104bool stopService(const std::string& id) {
105 LOGGER.info("Stopping {}", id);
106 auto service_instance = findServiceInstanceById(id);
107 if (service_instance == nullptr) {
108 LOGGER.warn("Service not running: {}", id);
109 return false;
110 }
111
112 service_instance->setState(State::Stopping);
113 service_instance->getService()->onStop(*service_instance);
114 service_instance->setState(State::Stopped);
115
116 instance_mutex.lock();
117 service_instance_map.erase(id);
118 instance_mutex.unlock();
119
120 if (service_instance.use_count() > 1) {
121 LOGGER.warn("Possible memory leak: service {} still has {} references", service_instance->getManifest().id, service_instance.use_count() - 1);
122 }
123
124 LOGGER.info("Stopped {}", id);
125
126 return true;
127}
128
129State getState(const std::string& id) {
130 auto service_instance = findServiceInstanceById(id);

Callers 1

detachDevicesFunction · 0.85

Calls 8

findServiceInstanceByIdFunction · 0.85
infoMethod · 0.80
warnMethod · 0.80
getServiceMethod · 0.80
setStateMethod · 0.45
onStopMethod · 0.45
lockMethod · 0.45
unlockMethod · 0.45

Tested by

no test coverage detected