mordor /mordor /daemon.cpp
19. #define CTRL_CASE(ctrl) \
20. case ctrl: \
21. return os << #ctrl; \
22.
23. #ifdef WINDOWS
48. enum ServiceCtrl {};
49.
50. std::ostream &operator <<(std::ostream &os, ServiceCtrl ctrl)
51. {
52. switch (ctrl) {
73. #endif
74. default:
75. return os << (int)ctrl;
76. }
77. }
20. case ctrl: \
21. return os << #ctrl; \
22.
23. #ifdef WINDOWS
48. enum ServiceCtrl {};
49.
50. std::ostream &operator <<(std::ostream &os, ServiceCtrl ctrl)
51. {
52. switch (ctrl) {
73. #endif
74. default:
75. return os << (int)ctrl;
76. }
77. }
36 matches | 454 lines | C++ | GitHub
mordor /mordor /workerpool.cpp
35. WorkerPool::tickle()
36. {
37. MORDOR_LOG_DEBUG(g_log) << this << " tickling";
38. m_semaphore.notify();
39. }
36. {
37. MORDOR_LOG_DEBUG(g_log) << this << " tickling";
38. m_semaphore.notify();
39. }
1 matches | 42 lines | C++ | GitHub
mordor /mordor /exception.cpp
60. for (size_t i = 0; i < backtrace.size(); ++i) {
61. if (i != 0)
62. os << std::endl;
63. #ifdef WINDOWS
64. os << backtrace[i];
65. if (g_useSymbols) {
66. char buf[sizeof(SYMBOL_INFO) + MAX_SYM_NAME - 1];
71. if (pSymFromAddr(GetCurrentProcess(), (DWORD64)backtrace[i],
72. &displacement64, symbol)) {
73. os << ": " << symbol->Name << "+" << displacement64;
74. }
75. IMAGEHLP_LINE64 line;
78. if (pSymGetLineFromAddr64(GetCurrentProcess(),
79. (DWORD64)backtrace[i], &displacement, &line)) {
80. os << ": " << line.FileName << "(" << line.LineNumber << ")+"
61. if (i != 0)
62. os << std::endl;
63. #ifdef WINDOWS
64. os << backtrace[i];
65. if (g_useSymbols) {
66. char buf[sizeof(SYMBOL_INFO) + MAX_SYM_NAME - 1];
71. if (pSymFromAddr(GetCurrentProcess(), (DWORD64)backtrace[i],
72. &displacement64, symbol)) {
73. os << ": " << symbol->Name << "+" << displacement64;
74. }
75. IMAGEHLP_LINE64 line;
78. if (pSymGetLineFromAddr64(GetCurrentProcess(),
79. (DWORD64)backtrace[i], &displacement, &line)) {
80. os << ": " << line.FileName << "(" << line.LineNumber << ")+"
48 matches | 372 lines | C++ | GitHub
mordor /mordor /config.cpp
346. catch(...)
347. {
348. MORDOR_LOG_WARNING(g_log) << "failed to monitor registry: " <<
349. boost::current_exception_diagnostic_information();
350. }
347. {
348. MORDOR_LOG_WARNING(g_log) << "failed to monitor registry: " <<
349. boost::current_exception_diagnostic_information();
350. }
1 matches | 443 lines | C++ | GitHub
mordor /mordor /ragel.cpp
123. eof = isEof ? pe : NULL;
124.
125. MORDOR_LOG_DEBUG(g_log) << charslice(p, pe - p);
126. exec();
127.
124.
125. MORDOR_LOG_DEBUG(g_log) << charslice(p, pe - p);
126. exec();
127.
1 matches | 178 lines | C++ | GitHub
mordor /mordor /iomanager_epoll.cpp
29. };
30.
31. static std::ostream &operator <<(std::ostream &os, epoll_ctl_op_t op)
32. {
33. switch ((int)op) {
34. case EPOLL_CTL_ADD:
35. return os << "EPOLL_CTL_ADD";
36. case EPOLL_CTL_MOD:
37. return os << "EPOLL_CTL_MOD";
38. case EPOLL_CTL_DEL:
39. return os << "EPOLL_CTL_DEL";
40. default:
41. return os << (int)op;
42. }
43. }
30.
31. static std::ostream &operator <<(std::ostream &os, epoll_ctl_op_t op)
32. {
33. switch ((int)op) {
34. case EPOLL_CTL_ADD:
35. return os << "EPOLL_CTL_ADD";
36. case EPOLL_CTL_MOD:
37. return os << "EPOLL_CTL_MOD";
38. case EPOLL_CTL_DEL:
39. return os << "EPOLL_CTL_DEL";
40. default:
41. return os << (int)op;
42. }
43. }
59 matches | 492 lines | C++ | GitHub
mordor /mordor /timer.cpp
105. Timer::cancel()
106. {
107. MORDOR_LOG_DEBUG(g_log) << this << " cancel";
108. boost::mutex::scoped_lock lock(m_manager->m_mutex);
109. if (m_dg) {
131. m_manager->m_timers.insert(shared_from_this());
132. lock.unlock();
133. MORDOR_LOG_DEBUG(g_log) << this << " refresh";
134. return true;
135. }
160. m_manager->m_tickled = true;
161. lock.unlock();
162. MORDOR_LOG_DEBUG(g_log) << this << " reset to " << m_us;
163. if (atFront)
164. m_manager->onTimerInsertedAtFront();
106. {
107. MORDOR_LOG_DEBUG(g_log) << this << " cancel";
108. boost::mutex::scoped_lock lock(m_manager->m_mutex);
109. if (m_dg) {
131. m_manager->m_timers.insert(shared_from_this());
132. lock.unlock();
133. MORDOR_LOG_DEBUG(g_log) << this << " refresh";
134. return true;
135. }
160. m_manager->m_tickled = true;
161. lock.unlock();
162. MORDOR_LOG_DEBUG(g_log) << this << " reset to " << m_us;
163. if (atFront)
164. m_manager->onTimerInsertedAtFront();
12 matches | 347 lines | C++ | GitHub
mordor /mordor /iomanager_iocp.cpp
26. {
27. m_handles[0] = CreateEventW(NULL, FALSE, FALSE, NULL);
28. MORDOR_LOG_DEBUG(g_logWaitBlock) << this << " CreateEventW(): " << m_handles[0]
29. << " (" << lastError() << ")";
30. if (!m_handles[0])
31. MORDOR_THROW_EXCEPTION_FROM_LAST_ERROR_API("CreateEventW");
32. m_reconfigured = CreateEventW(NULL, FALSE, FALSE, NULL);
33. MORDOR_LOG_DEBUG(g_logWaitBlock) << this << " CreateEventW(): "
34. << m_reconfigured << " (" << lastError() << ")";
35. if (!m_reconfigured) {
36. CloseHandle(m_handles[0]);
43. MORDOR_ASSERT(m_inUseCount <= 0);
44. BOOL bRet = CloseHandle(m_handles[0]);
45. MORDOR_LOG_DEBUG(g_logWaitBlock) << this << " CloseHandle("
46. << m_handles[0] << "): " << bRet << " (" << lastError() << ")";
27. m_handles[0] = CreateEventW(NULL, FALSE, FALSE, NULL);
28. MORDOR_LOG_DEBUG(g_logWaitBlock) << this << " CreateEventW(): " << m_handles[0]
29. << " (" << lastError() << ")";
30. if (!m_handles[0])
31. MORDOR_THROW_EXCEPTION_FROM_LAST_ERROR_API("CreateEventW");
32. m_reconfigured = CreateEventW(NULL, FALSE, FALSE, NULL);
33. MORDOR_LOG_DEBUG(g_logWaitBlock) << this << " CreateEventW(): "
34. << m_reconfigured << " (" << lastError() << ")";
35. if (!m_reconfigured) {
36. CloseHandle(m_handles[0]);
43. MORDOR_ASSERT(m_inUseCount <= 0);
44. BOOL bRet = CloseHandle(m_handles[0]);
45. MORDOR_LOG_DEBUG(g_logWaitBlock) << this << " CloseHandle("
46. << m_handles[0] << "): " << bRet << " (" << lastError() << ")";
43 matches | 493 lines | C++ | GitHub
mordor /mordor /iomanager_kqueue.cpp
20. {
21. m_kqfd = kqueue();
22. MORDOR_LOG_LEVEL(g_log, m_kqfd <= 0 ? Log::ERROR : Log::TRACE) << this
23. << " kqueue(): " << m_kqfd;
24. if (m_kqfd <= 0) {
25. MORDOR_THROW_EXCEPTION_FROM_LAST_ERROR_API("kqueue");
26. }
27. int rc = pipe(m_tickleFds);
28. MORDOR_LOG_LEVEL(g_log, rc ? Log::ERROR : Log::VERBOSE) << this << " pipe(): "
29. << rc << " (" << lastError() << ")";
30. if (rc) {
31. close(m_kqfd);
37. EV_SET(&event, m_tickleFds[0], EVFILT_READ, EV_ADD, 0, 0, NULL);
38. rc = kevent(m_kqfd, &event, 1, NULL, 0, NULL);
39. MORDOR_LOG_LEVEL(g_log, rc ? Log::ERROR : Log::VERBOSE) << this << " kevent("
21. m_kqfd = kqueue();
22. MORDOR_LOG_LEVEL(g_log, m_kqfd <= 0 ? Log::ERROR : Log::TRACE) << this
23. << " kqueue(): " << m_kqfd;
24. if (m_kqfd <= 0) {
25. MORDOR_THROW_EXCEPTION_FROM_LAST_ERROR_API("kqueue");
26. }
27. int rc = pipe(m_tickleFds);
28. MORDOR_LOG_LEVEL(g_log, rc ? Log::ERROR : Log::VERBOSE) << this << " pipe(): "
29. << rc << " (" << lastError() << ")";
30. if (rc) {
31. close(m_kqfd);
37. EV_SET(&event, m_tickleFds[0], EVFILT_READ, EV_ADD, 0, 0, NULL);
38. rc = kevent(m_kqfd, &event, 1, NULL, 0, NULL);
39. MORDOR_LOG_LEVEL(g_log, rc ? Log::ERROR : Log::VERBOSE) << this << " kevent("
28 matches | 358 lines | C++ | GitHub
mordor /mordor /string.cpp
37. if(*ptr == '=') {
38. ++padding;
39. packed <<= 6;
40. continue;
41. }
59. return ""; // invalid character
60.
61. packed = (packed << 6) | val;
62. }
63. if (i != 4)
102. int padding = 0;
103. for(; i < 3 && ptr < end; ++i, ++ptr)
104. packed = (packed << 8) | *ptr;
105. if(i == 2)
106. padding = 1;
38. ++padding;
39. packed <<= 6;
40. continue;
41. }
59. return ""; // invalid character
60.
61. packed = (packed << 6) | val;
62. }
63. if (i != 4)
102. int padding = 0;
103. for(; i < 3 && ptr < end; ++i, ++ptr)
104. packed = (packed << 8) | *ptr;
105. if(i == 2)
106. padding = 1;
9 matches | 727 lines | C++ | GitHub
mordor /mordor /socket.cpp
58. };
59.
60. std::ostream &operator <<(std::ostream &os, Family family)
61. {
62. switch (family)
63. {
64. case UNSPECIFIED:
65. return os << "AF_UNSPEC";
66. case IP4:
67. return os << "AF_INET";
68. case IP6:
69. return os << "AF_INET6";
70. default:
71. return os << (int)family;
72. }
59.
60. std::ostream &operator <<(std::ostream &os, Family family)
61. {
62. switch (family)
63. {
64. case UNSPECIFIED:
65. return os << "AF_UNSPEC";
66. case IP4:
67. return os << "AF_INET";
68. case IP6:
69. return os << "AF_INET6";
70. default:
71. return os << (int)family;
72. }
146 matches | 1933 lines | C++ | GitHub
mordor /mordor /fiber.cpp
673. }
674.
675. std::ostream &operator<<(std::ostream &os, Fiber::State state)
676. {
677. switch (state) {
678. case Fiber::INIT:
679. return os << "INIT";
680. case Fiber::HOLD:
681. return os << "HOLD";
682. case Fiber::EXEC:
683. return os << "EXEC";
684. case Fiber::EXCEPT:
685. return os << "EXCEPT";
686. case Fiber::TERM:
687. return os << "TERM";
674.
675. std::ostream &operator<<(std::ostream &os, Fiber::State state)
676. {
677. switch (state) {
678. case Fiber::INIT:
679. return os << "INIT";
680. case Fiber::HOLD:
681. return os << "HOLD";
682. case Fiber::EXEC:
683. return os << "EXEC";
684. case Fiber::EXCEPT:
685. return os << "EXCEPT";
686. case Fiber::TERM:
687. return os << "TERM";
7 matches | 694 lines | C++ | GitHub
mordor /mordor /statistics.cpp
22. {
23. std::string indent(level++ * 4, ' ');
24. os << indent << typeid(stat).name() << ": " << stat;
25. if (stat.units)
26. os << " " << stat.units;
27. os << std::endl;
28. const Statistic *substat = stat.begin();
29. while (substat) {
46. it != statistics().end();
47. ++it) {
48. os << it->first;
49. if (!it->second.first.empty())
50. os << " (" << it->second.first << ")";
51. os << ": ";
52. Mordor::dump(os, *it->second.second.get());
23. std::string indent(level++ * 4, ' ');
24. os << indent << typeid(stat).name() << ": " << stat;
25. if (stat.units)
26. os << " " << stat.units;
27. os << std::endl;
28. const Statistic *substat = stat.begin();
29. while (substat) {
46. it != statistics().end();
47. ++it) {
48. os << it->first;
49. if (!it->second.first.empty())
50. os << " (" << it->second.first << ")";
51. os << ": ";
52. Mordor::dump(os, *it->second.second.get());
6 matches | 58 lines | C++ | GitHub
mordor /mordor /log.cpp
214. {
215. std::ostringstream os;
216. os << now << " " << elapsed << " " << level << " " << thread << " "
217. << fiber << " " << logger << " " << file << ":" << line << " "
218. << str << std::endl;
219. std::cout << os.str();
220. std::cout.flush();
221. }
230. {
231. std::wostringstream os;
232. os << now << " " << elapsed << " " << level << " " << thread << " "
233. << fiber << " " << toUtf16(logger) << " " << toUtf16(file)
234. << ":" << line << " " << toUtf16(str) << std::endl;
235. OutputDebugStringW(os.str().c_str());
236. }
215. std::ostringstream os;
216. os << now << " " << elapsed << " " << level << " " << thread << " "
217. << fiber << " " << logger << " " << file << ":" << line << " "
218. << str << std::endl;
219. std::cout << os.str();
220. std::cout.flush();
221. }
230. {
231. std::wostringstream os;
232. os << now << " " << elapsed << " " << level << " " << thread << " "
233. << fiber << " " << toUtf16(logger) << " " << toUtf16(file)
234. << ":" << line << " " << toUtf16(str) << std::endl;
235. OutputDebugStringW(os.str().c_str());
236. }
17 matches | 532 lines | C++ | GitHub
mordor /mordor /scheduler.cpp
55. Scheduler::start()
56. {
57. MORDOR_LOG_VERBOSE(g_log) << this << " starting " << m_threadCount << " threads";
58. boost::mutex::scoped_lock lock(m_mutex);
59. if (!m_stopping)
87. m_threadCount == 0 &&
88. (m_rootFiber->state() == Fiber::TERM || m_rootFiber->state() == Fiber::INIT)) {
89. MORDOR_LOG_VERBOSE(g_log) << this << " stopped";
90. m_stopping = true;
91. // A derived class may inhibit stopping while it has things to do in
104. exitOnThisFiber = true;
105. // First switch to the correct thread
106. MORDOR_LOG_DEBUG(g_log) << this
107. << " switching to root thread to stop";
108. switchTo(m_rootThread);
56. {
57. MORDOR_LOG_VERBOSE(g_log) << this << " starting " << m_threadCount << " threads";
58. boost::mutex::scoped_lock lock(m_mutex);
59. if (!m_stopping)
87. m_threadCount == 0 &&
88. (m_rootFiber->state() == Fiber::TERM || m_rootFiber->state() == Fiber::INIT)) {
89. MORDOR_LOG_VERBOSE(g_log) << this << " stopped";
90. m_stopping = true;
91. // A derived class may inhibit stopping while it has things to do in
104. exitOnThisFiber = true;
105. // First switch to the correct thread
106. MORDOR_LOG_DEBUG(g_log) << this
107. << " switching to root thread to stop";
108. switchTo(m_rootThread);
30 matches | 481 lines | C++ | GitHub
mordor /mordor /eventloop.cpp
75. {
76. while (!stopping()) {
77. MORDOR_LOG_DEBUG(g_log) << m_messageWindow << " Starting new message pump";
78. schedule(boost::bind(&EventLoop::messagePump, this));
79. Fiber::yield();
84. EventLoop::tickle()
85. {
86. MORDOR_LOG_TRACE(g_log) << m_messageWindow << " tickling";
87. if (!PostMessage(m_messageWindow, g_tickleMessage, 0, 0))
88. MORDOR_THROW_EXCEPTION_FROM_LAST_ERROR_API("PostMessage");
109.
110. if (uMsg == g_tickleMessage) {
111. MORDOR_LOG_TRACE(g_log) << hWnd << " received tickle";
112. Scheduler::yield();
113. return 0;
76. while (!stopping()) {
77. MORDOR_LOG_DEBUG(g_log) << m_messageWindow << " Starting new message pump";
78. schedule(boost::bind(&EventLoop::messagePump, this));
79. Fiber::yield();
84. EventLoop::tickle()
85. {
86. MORDOR_LOG_TRACE(g_log) << m_messageWindow << " tickling";
87. if (!PostMessage(m_messageWindow, g_tickleMessage, 0, 0))
88. MORDOR_THROW_EXCEPTION_FROM_LAST_ERROR_API("PostMessage");
109.
110. if (uMsg == g_tickleMessage) {
111. MORDOR_LOG_TRACE(g_log) << hWnd << " received tickle";
112. Scheduler::yield();
113. return 0;
7 matches | 175 lines | C++ | GitHub
mordor /mordor /util.cpp
53. rh += (rl >> 32);
54. res.l.high = (uint32_t)(rh / c);
55. res.l.low = (uint32_t)((((rh % c) << 32) + (rl & 0xffffffff)) / c);
56. return res.ll;
57. }
54. res.l.high = (uint32_t)(rh / c);
55. res.l.low = (uint32_t)((((rh % c) << 32) + (rl & 0xffffffff)) / c);
56. return res.ll;
57. }
1 matches | 60 lines | C++ | GitHub
mordor /mordor/examples /iombench.cpp
153. m_totalClients += newClients;
154.
155. MORDOR_LOG_DEBUG(g_log) << "prep "
156. << "newClients " << newClients << " "
157. << "newActive " << newActive << " "
158. << "iters " << iters;
159.
160. for (size_t i = 0; i < newClients; i++) {
185. m_opsDone = 0;
186. m_round++;
187. MORDOR_LOG_DEBUG(g_log) << "round start " << m_round
188. << " " << m_clientsDone << " " << m_totalClients;
189. m_readyCond.broadcast();
190.
192. FiberMutex::ScopedLock lock(m_mutex);
154.
155. MORDOR_LOG_DEBUG(g_log) << "prep "
156. << "newClients " << newClients << " "
157. << "newActive " << newActive << " "
158. << "iters " << iters;
159.
160. for (size_t i = 0; i < newClients; i++) {
185. m_opsDone = 0;
186. m_round++;
187. MORDOR_LOG_DEBUG(g_log) << "round start " << m_round
188. << " " << m_clientsDone << " " << m_totalClients;
189. m_readyCond.broadcast();
190.
192. FiberMutex::ScopedLock lock(m_mutex);
12 matches | 321 lines | C++ | GitHub
mordor /mordor/examples /echoserver.cpp
148. ioManager.dispatch();
149. } catch (...) {
150. std::cerr << boost::current_exception_diagnostic_information() << std::endl;
151. return 1;
152. }
149. } catch (...) {
150. std::cerr << boost::current_exception_diagnostic_information() << std::endl;
151. return 1;
152. }
1 matches | 161 lines | C++ | GitHub
mordor /mordor/examples /udpstats.cpp
18. Config::loadFromEnvironment();
19. if (argc != 2) {
20. std::cerr << "Usage: <address>" << std::endl;
21. return 1;
22. }
38. }
39. } catch (...) {
40. std::cerr << boost::current_exception_diagnostic_information() << std::endl;
41. return 2;
42. }
19. if (argc != 2) {
20. std::cerr << "Usage: <address>" << std::endl;
21. return 1;
22. }
38. }
39. } catch (...) {
40. std::cerr << boost::current_exception_diagnostic_information() << std::endl;
41. return 2;
42. }
2 matches | 45 lines | C++ | GitHub

