2023-01-16 09:10:53 +00:00
|
|
|
#pragma once
|
|
|
|
|
2023-01-17 13:56:56 +00:00
|
|
|
#include <thread>
|
2023-01-18 16:34:17 +00:00
|
|
|
#include <variant>
|
|
|
|
#include "arb.h"
|
|
|
|
|
|
|
|
typedef std::variant<std::string> LogcatThreadItem;
|
2023-01-17 13:56:56 +00:00
|
|
|
|
|
|
|
class LogcatThread {
|
|
|
|
public:
|
2023-01-16 09:10:53 +00:00
|
|
|
// https://stackoverflow.com/a/2173764
|
2023-01-17 13:56:56 +00:00
|
|
|
LogcatThread(const LogcatThread&) = delete;
|
|
|
|
LogcatThread& operator=(const LogcatThread&) = delete;
|
2023-01-16 09:10:53 +00:00
|
|
|
|
2023-01-17 16:22:12 +00:00
|
|
|
LogcatThread();
|
2023-01-17 13:56:56 +00:00
|
|
|
~LogcatThread();
|
2023-01-17 16:22:12 +00:00
|
|
|
void request_stop();
|
2023-01-17 13:56:56 +00:00
|
|
|
void join();
|
2023-01-16 09:10:53 +00:00
|
|
|
|
2023-01-18 16:34:17 +00:00
|
|
|
AtomicRingBuffer<LogcatThreadItem> atomic_ring_buffer;
|
|
|
|
|
2023-01-17 13:56:56 +00:00
|
|
|
private:
|
2023-01-17 16:22:12 +00:00
|
|
|
void _run(std::stop_token stoken);
|
2023-01-16 09:10:53 +00:00
|
|
|
|
2023-01-17 13:56:56 +00:00
|
|
|
int _epoll_fd = -1;
|
2023-01-17 14:44:17 +00:00
|
|
|
int _stdout_read_fd = -1;
|
|
|
|
int _stdout_write_fd = -1;
|
|
|
|
int _stderr_read_fd = -1;
|
|
|
|
int _stderr_write_fd = -1;
|
2023-01-17 16:22:12 +00:00
|
|
|
std::stop_source _stop_source;
|
2023-01-17 13:56:56 +00:00
|
|
|
std::thread _thread;
|
|
|
|
};
|