MCPcopy Create free account
hub / github.com/PHZ76/RtspServer / Loop

Method Loop

src/net/EventLoop.cpp:51–99  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

49}
50
51void EventLoop::Loop()
52{
53 std::lock_guard<std::mutex> locker(mutex_);
54
55 if (!task_schedulers_.empty()) {
56 return ;
57 }
58
59 for (uint32_t n = 0; n < num_threads_; n++)
60 {
61#if defined(__linux) || defined(__linux__)
62 std::shared_ptr<TaskScheduler> task_scheduler_ptr(new EpollTaskScheduler(n));
63#elif defined(WIN32) || defined(_WIN32)
64 std::shared_ptr<TaskScheduler> task_scheduler_ptr(new SelectTaskScheduler(n));
65#endif
66 task_schedulers_.push_back(task_scheduler_ptr);
67 std::shared_ptr<std::thread> thread(new std::thread(&TaskScheduler::Start, task_scheduler_ptr.get()));
68 thread->native_handle();
69 threads_.push_back(thread);
70 }
71
72 const int priority = TASK_SCHEDULER_PRIORITY_REALTIME;
73
74 for (auto iter : threads_)
75 {
76#if defined(__linux) || defined(__linux__)
77
78#elif defined(WIN32) || defined(_WIN32)
79 switch (priority)
80 {
81 case TASK_SCHEDULER_PRIORITY_LOW:
82 SetThreadPriority(iter->native_handle(), THREAD_PRIORITY_BELOW_NORMAL);
83 break;
84 case TASK_SCHEDULER_PRIORITY_NORMAL:
85 SetThreadPriority(iter->native_handle(), THREAD_PRIORITY_NORMAL);
86 break;
87 case TASK_SCHEDULER_PRIORITYO_HIGH:
88 SetThreadPriority(iter->native_handle(), THREAD_PRIORITY_ABOVE_NORMAL);
89 break;
90 case TASK_SCHEDULER_PRIORITY_HIGHEST:
91 SetThreadPriority(iter->native_handle(), THREAD_PRIORITY_HIGHEST);
92 break;
93 case TASK_SCHEDULER_PRIORITY_REALTIME:
94 SetThreadPriority(iter->native_handle(), THREAD_PRIORITY_TIME_CRITICAL);
95 break;
96 }
97#endif
98 }
99}
100
101void EventLoop::Quit()
102{

Callers 1

EventLoopMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected