#ifndef __Thread_h__
#define __Thread_h__

#include "includes"
#include "Log.h"
#include "Object.h"
#include "TCPSession.h"
#include "ThreadScope.h"

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 Object {

    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
