MCPcopy Create free account
hub / github.com/chenshuo/muduo / onConnection

Method onConnection

examples/asio/chat/server_threaded_efficient.cc:41–62  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

39
40 private:
41 void onConnection(const TcpConnectionPtr& conn)
42 {
43 LOG_INFO << conn->peerAddress().toIpPort() << " -> "
44 << conn->localAddress().toIpPort() << " is "
45 << (conn->connected() ? "UP" : "DOWN");
46
47 MutexLockGuard lock(mutex_);
48 if (!connections_.unique())
49 {
50 connections_.reset(new ConnectionList(*connections_));
51 }
52 assert(connections_.unique());
53
54 if (conn->connected())
55 {
56 connections_->insert(conn);
57 }
58 else
59 {
60 connections_->erase(conn);
61 }
62 }
63
64 typedef std::set<TcpConnectionPtr> ConnectionList;
65 typedef std::shared_ptr<ConnectionList> ConnectionListPtr;

Callers

nothing calls this directly

Calls 4

insertMethod · 0.80
toIpPortMethod · 0.45
connectedMethod · 0.45
resetMethod · 0.45

Tested by

no test coverage detected