MCPcopy Create free account
hub / github.com/ClickHouse/ClickHouse / run

Method run

base/poco/Net/src/SocketReactor.cpp:65–134  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

63
64
65void SocketReactor::run()
66{
67 _pThread = Thread::current();
68
69 Socket::SocketList readable;
70 Socket::SocketList writable;
71 Socket::SocketList except;
72
73 while (!_stop)
74 {
75 try
76 {
77 readable.clear();
78 writable.clear();
79 except.clear();
80 int nSockets = 0;
81 {
82 FastMutex::ScopedLock lock(_mutex);
83 for (EventHandlerMap::iterator it = _handlers.begin(); it != _handlers.end(); ++it)
84 {
85 if (it->second->accepts(_pReadableNotification))
86 {
87 readable.push_back(it->first);
88 nSockets++;
89 }
90 if (it->second->accepts(_pWritableNotification))
91 {
92 writable.push_back(it->first);
93 nSockets++;
94 }
95 if (it->second->accepts(_pErrorNotification))
96 {
97 except.push_back(it->first);
98 nSockets++;
99 }
100 }
101 }
102 if (nSockets == 0)
103 {
104 onIdle();
105 Thread::trySleep(static_cast<long>(_timeout.totalMilliseconds()));
106 }
107 else if (Socket::select(readable, writable, except, _timeout))
108 {
109 onBusy();
110
111 for (Socket::SocketList::iterator it = readable.begin(); it != readable.end(); ++it)
112 dispatch(*it, _pReadableNotification);
113 for (Socket::SocketList::iterator it = writable.begin(); it != writable.end(); ++it)
114 dispatch(*it, _pWritableNotification);
115 for (Socket::SocketList::iterator it = except.begin(); it != except.end(); ++it)
116 dispatch(*it, _pErrorNotification);
117 }
118 else onTimeout();
119 }
120 catch (Exception& exc)
121 {
122 ErrorHandler::handle(exc);

Callers

nothing calls this directly

Calls 8

handleFunction · 0.85
selectFunction · 0.50
clearMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
acceptsMethod · 0.45
push_backMethod · 0.45
totalMillisecondsMethod · 0.45

Tested by

no test coverage detected