MCPcopy Create free account
hub / github.com/e2wugui/zeze / Select

Method Select

cxx/Net.cpp:516–529  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

514 std::unordered_map<std::shared_ptr<Socket>, int> pending;
515
516 void Select(const std::shared_ptr<Socket>& sock, int add, int remove)
517 {
518 std::lock_guard<std::mutex> g(mutexPending);
519 int oldFlags = sock->selectorFlags;
520 int newFlags = (oldFlags & ~remove) | add;
521 if (oldFlags != newFlags)
522 {
523 sock->selectorFlags = newFlags;
524 auto rc = pending.insert(std::make_pair(sock, newFlags));
525 if (false == rc.second) // 已经存在,更新flags
526 rc.first->second = newFlags;
527 Wakeup();
528 }
529 }
530
531 int wakeupfds[2];
532 bool loop = true;

Callers 5

MakeMethod · 0.80
CloseMethod · 0.80
OnSendMethod · 0.80
SendMethod · 0.80
Net.cppFile · 0.80

Calls 1

insertMethod · 0.45

Tested by

no test coverage detected