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

Method AddWatcher

src/brpc/details/naming_service_thread.cpp:338–354  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

336}
337
338int NamingServiceThread::AddWatcher(NamingServiceWatcher* watcher,
339 const NamingServiceFilter* filter) {
340 if (watcher == NULL) {
341 LOG(ERROR) << "Param[watcher] is NULL";
342 return -1;
343 }
344 BAIDU_SCOPED_LOCK(_mutex);
345 if (_watchers.emplace(watcher, filter).second) {
346 if (!_last_sockets.empty()) {
347 std::vector<ServerId> added_ids;
348 ServerNodeWithId2ServerId(_last_sockets, &added_ids, filter);
349 watcher->OnAddedServers(added_ids);
350 }
351 return 0;
352 }
353 return -1;
354}
355
356int NamingServiceThread::RemoveWatcher(NamingServiceWatcher* watcher) {
357 if (watcher == NULL) {

Callers 2

InitMethod · 0.45
InitMethod · 0.45

Calls 2

emptyMethod · 0.45
OnAddedServersMethod · 0.45

Tested by

no test coverage detected