1 #include "../include/threadcontroller.h"
\r
2 #include "../include/option.h"
\r
3 #include "../include/freenet/freenetmasterthread.h"
\r
4 #include "../include/nntp/nntplistener.h"
\r
5 #include "../include/http/httpthread.h"
\r
11 ThreadController::~ThreadController()
\r
16 void ThreadController::ReadConfig()
\r
19 std::string tempval="";
\r
20 Option::Instance()->Get("StartFreenetUpdater",tempval);
\r
23 m_startfreenet=true;
\r
27 m_startfreenet=false;
\r
31 Option::Instance()->Get("StartNNTP",tempval);
\r
42 Option::Instance()->Get("StartHTTP",tempval);
\r
54 void ThreadController::RestartThreads()
\r
56 m_log->WriteLog(LogFile::LOGLEVEL_INFO,"ThreadController::RestartThreads restarting threads.");
\r
61 void ThreadController::ShutdownFreenetThread()
\r
65 m_log->WriteLog(LogFile::LOGLEVEL_INFO,"ThreadController::ShutdownFreenetThread shutting down Freenet thread.");
\r
66 m_freenetthread->Cancel();
\r
67 m_freenetthread->Join();
\r
68 delete m_freenetthread;
\r
69 m_freenetthread=NULL;
\r
73 void ThreadController::ShutdownHTTPThread()
\r
77 m_log->WriteLog(LogFile::LOGLEVEL_INFO,"ThreadController::ShutdownHTTPThread shutting down HTTP thread.");
\r
78 m_httpthread->Cancel();
\r
79 m_httpthread->Join();
\r
80 delete m_httpthread;
\r
85 void ThreadController::ShutdownNNTPThread()
\r
89 m_log->WriteLog(LogFile::LOGLEVEL_INFO,"ThreadController::ShutdownNNTPThread shutting down NNTP thread.");
\r
90 m_nntpthread->Cancel();
\r
91 m_nntpthread->Join();
\r
92 delete m_nntpthread;
\r
97 void ThreadController::ShutdownThreads()
\r
99 ShutdownFreenetThread();
\r
100 ShutdownNNTPThread();
\r
101 ShutdownHTTPThread();
\r
104 void ThreadController::StartFreenetThread()
\r
106 m_log->WriteLog(LogFile::LOGLEVEL_INFO,"ThreadController::StartFreenetThread starting Freenet thread.");
\r
107 m_freenetthread=new PThread::Thread(new FreenetMasterThread());
\r
110 void ThreadController::StartHTTPThread()
\r
112 m_log->WriteLog(LogFile::LOGLEVEL_INFO,"ThreadController::StartHTTPThread starting HTTP thread.");
\r
113 m_httpthread=new PThread::Thread(new HTTPThread());
\r
116 void ThreadController::StartNNTPThread()
\r
118 m_log->WriteLog(LogFile::LOGLEVEL_INFO,"ThreadController::StartNNTPThread starting NNTP thread.");
\r
119 m_nntpthread=new PThread::Thread(new NNTPListener());
\r
122 void ThreadController::StartThreads()
\r
128 StartFreenetThread();
\r