Seperate epoll into its own function
This commit is contained in:
parent
6cca794fee
commit
35ee4d3ff4
|
@ -204,23 +204,15 @@ void LogcatThread::_handle_line(char* buf, size_t length, bool is_stdout) {
|
||||||
this->_put_if_not_stopped(std::move(log_entry));
|
this->_put_if_not_stopped(std::move(log_entry));
|
||||||
}
|
}
|
||||||
|
|
||||||
void LogcatThread::_run(std::stop_token stoken) {
|
void LogcatThread::_run_epoll_round() {
|
||||||
struct epoll_event events[EPOLL_MAX_EVENTS];
|
struct epoll_event events[EPOLL_MAX_EVENTS];
|
||||||
|
|
||||||
while (!stoken.stop_requested()) {
|
|
||||||
#ifndef NDEBUG
|
|
||||||
if (this->debug_log_request.test()) {
|
|
||||||
this->_put_if_not_stopped(format_log("A log entry from the logcat thread :D"));
|
|
||||||
this->debug_log_request.clear();
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
int ready_fds = epoll_wait(this->_epoll_fd, events, EPOLL_MAX_EVENTS, 1000);
|
int ready_fds = epoll_wait(this->_epoll_fd, events, EPOLL_MAX_EVENTS, 1000);
|
||||||
if (ready_fds == -1) {
|
if (ready_fds == -1) {
|
||||||
std::string log_entry = format_log(std::string("epoll_wait(): ") + strerror(errno));
|
std::string log_entry = format_log(std::string("epoll_wait(): ") + strerror(errno));
|
||||||
printf("%s\n", log_entry.c_str());
|
printf("%s\n", log_entry.c_str());
|
||||||
this->_put_if_not_stopped(std::move(log_entry));
|
this->_put_if_not_stopped(std::move(log_entry));
|
||||||
break;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i=0; i < ready_fds; i++) {
|
for (int i=0; i < ready_fds; i++) {
|
||||||
|
@ -240,4 +232,16 @@ void LogcatThread::_run(std::stop_token stoken) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void LogcatThread::_run(std::stop_token stoken) {
|
||||||
|
while (!stoken.stop_requested()) {
|
||||||
|
#ifndef NDEBUG
|
||||||
|
if (this->debug_log_request.test()) {
|
||||||
|
this->_put_if_not_stopped(format_log("A log entry from the logcat thread :D"));
|
||||||
|
this->debug_log_request.clear();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
this->_run_epoll_round();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,6 +28,7 @@ public:
|
||||||
private:
|
private:
|
||||||
void _put_if_not_stopped(LogcatThreadItem item);
|
void _put_if_not_stopped(LogcatThreadItem item);
|
||||||
void _handle_line(char* buf, size_t length, bool is_stdout);
|
void _handle_line(char* buf, size_t length, bool is_stdout);
|
||||||
|
void _run_epoll_round();
|
||||||
void _run(std::stop_token stoken);
|
void _run(std::stop_token stoken);
|
||||||
|
|
||||||
int _epoll_fd = -1;
|
int _epoll_fd = -1;
|
||||||
|
|
Loading…
Reference in New Issue