ServerCore/Thread.h
2024-07-10 13:30:18 -07:00

54 lines
1.2 KiB
C++

#ifndef __Thread_h__
#define __Thread_h__
#include "Log.h"
#include "TCPSession.h"
#include "ThreadScope.h"
#include <thread>
namespace core {
class EPoll;
///
/// Thread
///
/// This thread object is designed to be the thread processor for the EPoll object. It wraps the thread
/// object to allow maintaining a status value for monitoring the thread activity. EPoll will instantiate
/// a Thread object for each thread specified in the EPoll's start method.
///
class Thread {
public:
Thread(EPoll &ePoll);
Thread(EPoll &ePoll, ThreadScope *thread);
~Thread();
///
/// Start the thread object. This will cause the epoll scheduler to commence reading the epoll queue.
///
void start();
void join();
std::string getStatus();
pid_t getThreadId();
int getCount();
void output(std::stringstream &data);
private:
EPoll &ePoll; // The EPoll control object.
std::string status;
int count;
std::thread *_thread;
void print_thread_start_log();
pid_t threadId;
void run();
ThreadScope *thread;
};
}
#endif