X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fthreadcontroller.cpp;fp=src%2Fthreadcontroller.cpp;h=0000000000000000000000000000000000000000;hb=dec33c63afafabf83c3039e916725cac6faef9b3;hp=48984e881f0695d28cf71c8bfcaf1c3297a4df50;hpb=9b22dd53fe62e312c1647310b7ec43aa127090af;p=fms.git diff --git a/src/threadcontroller.cpp b/src/threadcontroller.cpp deleted file mode 100644 index 48984e8..0000000 --- a/src/threadcontroller.cpp +++ /dev/null @@ -1,139 +0,0 @@ -#include "../include/threadcontroller.h" -#include "../include/option.h" -#include "../include/freenet/freenetmasterthread.h" -#include "../include/nntp/nntplistener.h" -#include "../include/http/httpthread.h" - -#ifdef XMEM - #include -#endif - -ThreadController::~ThreadController() -{ - ShutdownThreads(); -} - -void ThreadController::ReadConfig() -{ - - std::string tempval=""; - Option::Instance()->Get("StartFreenetUpdater",tempval); - if(tempval=="true") - { - m_startfreenet=true; - } - else - { - m_startfreenet=false; - } - - tempval=""; - Option::Instance()->Get("StartNNTP",tempval); - if(tempval=="true") - { - m_startnntp=true; - } - else - { - m_startnntp=false; - } - - tempval=""; - Option::Instance()->Get("StartHTTP",tempval); - if(tempval=="true") - { - m_starthttp=true; - } - else - { - m_starthttp=false; - } - -} - -void ThreadController::RestartThreads() -{ - m_log->WriteLog(LogFile::LOGLEVEL_INFO,"ThreadController::RestartThreads restarting threads."); - ShutdownThreads(); - StartThreads(); -} - -void ThreadController::ShutdownFreenetThread() -{ - if(m_freenetthread) - { - m_log->WriteLog(LogFile::LOGLEVEL_INFO,"ThreadController::ShutdownFreenetThread shutting down Freenet thread."); - m_freenetthread->Cancel(); - m_freenetthread->Join(); - delete m_freenetthread; - m_freenetthread=NULL; - } -} - -void ThreadController::ShutdownHTTPThread() -{ - if(m_httpthread) - { - m_log->WriteLog(LogFile::LOGLEVEL_INFO,"ThreadController::ShutdownHTTPThread shutting down HTTP thread."); - m_httpthread->Cancel(); - m_httpthread->Join(); - delete m_httpthread; - m_httpthread=NULL; - } -} - -void ThreadController::ShutdownNNTPThread() -{ - if(m_nntpthread) - { - m_log->WriteLog(LogFile::LOGLEVEL_INFO,"ThreadController::ShutdownNNTPThread shutting down NNTP thread."); - m_nntpthread->Cancel(); - m_nntpthread->Join(); - delete m_nntpthread; - m_nntpthread=NULL; - } -} - -void ThreadController::ShutdownThreads() -{ - ShutdownFreenetThread(); - ShutdownNNTPThread(); - ShutdownHTTPThread(); -} - -void ThreadController::StartFreenetThread() -{ - m_log->WriteLog(LogFile::LOGLEVEL_INFO,"ThreadController::StartFreenetThread starting Freenet thread."); - m_freenetthread=new PThread::Thread(new FreenetMasterThread()); -} - -void ThreadController::StartHTTPThread() -{ - m_log->WriteLog(LogFile::LOGLEVEL_INFO,"ThreadController::StartHTTPThread starting HTTP thread."); - m_httpthread=new PThread::Thread(new HTTPThread()); -} - -void ThreadController::StartNNTPThread() -{ - m_log->WriteLog(LogFile::LOGLEVEL_INFO,"ThreadController::StartNNTPThread starting NNTP thread."); - m_nntpthread=new PThread::Thread(new NNTPListener()); -} - -void ThreadController::StartThreads() -{ - ReadConfig(); - - if(m_startfreenet) - { - StartFreenetThread(); - } - if(m_startnntp) - { - StartNNTPThread(); - } - if(m_starthttp) - { - StartHTTPThread(); - } -} -