From 547857beb8126f3865f5b5d4ef6bf2fdb61424ca Mon Sep 17 00:00:00 2001 From: Eran Ifrah <eran@codelite.org> Date: Wed, 23 Feb 2022 13:41:06 +0200 Subject: [PATCH] code cleanup reduced the number of threads created by CodeLite --- Interfaces/imanager.h | 6 - LiteEditor/cl_editor.cpp | 2 - LiteEditor/context_cpp.cpp | 1 - LiteEditor/dbcontentcacher.cpp | 57 ------ LiteEditor/dbcontentcacher.h | 44 ----- LiteEditor/frame.cpp | 5 - LiteEditor/manager.cpp | 14 -- LiteEditor/manager.h | 14 +- LiteEditor/pluginmanager.cpp | 2 - LiteEditor/pluginmanager.h | 2 - LiteEditor/refactorindexbuildjob.cpp | 82 --------- LiteEditor/refactorindexbuildjob.h | 46 ----- LiteEditor/stringhighlighterjob.h | 3 +- Plugin/job.cpp | 54 ------ Plugin/job.h | 79 --------- Plugin/jobqueue.cpp | 136 -------------- Plugin/jobqueue.h | 166 ------------------ codelitephp/PHPParser/PHPSymbolsCacher.cpp | 29 --- codelitephp/PHPParser/PHPSymbolsCacher.h | 47 ----- codelitephp/PHPParser/php_code_completion.cpp | 3 - cppchecker/cppcheck_settings.h | 5 +- cppchecker/cppchecker.cpp | 1 - 22 files changed, 7 insertions(+), 791 deletions(-) delete mode 100644 LiteEditor/dbcontentcacher.cpp delete mode 100644 LiteEditor/dbcontentcacher.h delete mode 100644 LiteEditor/refactorindexbuildjob.cpp delete mode 100644 LiteEditor/refactorindexbuildjob.h delete mode 100644 Plugin/job.cpp delete mode 100644 Plugin/job.h delete mode 100644 Plugin/jobqueue.cpp delete mode 100644 Plugin/jobqueue.h delete mode 100644 codelitephp/PHPParser/PHPSymbolsCacher.cpp delete mode 100644 codelitephp/PHPParser/PHPSymbolsCacher.h diff --git a/Interfaces/imanager.h b/Interfaces/imanager.h index f24f5e22ee..c845472215 100644 --- a/Interfaces/imanager.h +++ b/Interfaces/imanager.h @@ -50,7 +50,6 @@ class clWorkspaceView; class TagsManager; class clCxxWorkspace; class EnvironmentConfig; -class JobQueue; class wxApp; class IPlugin; class BuildManager; @@ -365,11 +364,6 @@ class IManager * @sa EnvironmentConfig */ virtual EnvironmentConfig* GetEnv() = 0; - /** - * @brief return a pointer to the job queue manager - * @return job queue manager - */ - virtual JobQueue* GetJobQueue() = 0; /** * @brief return the project execution command as set in the project's settings diff --git a/LiteEditor/cl_editor.cpp b/LiteEditor/cl_editor.cpp index b162a001bc..864b8e6550 100644 --- a/LiteEditor/cl_editor.cpp +++ b/LiteEditor/cl_editor.cpp @@ -63,8 +63,6 @@ #include "frame.h" #include "globals.h" #include "imanager.h" -#include "job.h" -#include "jobqueue.h" #include "lexer_configuration.h" #include "localworkspace.h" #include "macromanager.h" diff --git a/LiteEditor/context_cpp.cpp b/LiteEditor/context_cpp.cpp index 38d121ab0e..9f2986d999 100644 --- a/LiteEditor/context_cpp.cpp +++ b/LiteEditor/context_cpp.cpp @@ -71,7 +71,6 @@ #include "new_quick_watch_dlg.h" #include "pluginmanager.h" #include "precompiled_header.h" -#include "refactorindexbuildjob.h" #include "renamesymboldlg.h" #include "setters_getters_dlg.h" #include "symbols_dialog.h" diff --git a/LiteEditor/dbcontentcacher.cpp b/LiteEditor/dbcontentcacher.cpp deleted file mode 100644 index bb1c2016f2..0000000000 --- a/LiteEditor/dbcontentcacher.cpp +++ /dev/null @@ -1,57 +0,0 @@ -////////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// -// -// copyright : (C) 2014 Eran Ifrah -// file name : dbcontentcacher.cpp -// -// ------------------------------------------------------------------------- -// A -// _____ _ _ _ _ -// / __ \ | | | | (_) | -// | / \/ ___ __| | ___| | _| |_ ___ -// | | / _ \ / _ |/ _ \ | | | __/ _ ) -// | \__/\ (_) | (_| | __/ |___| | || __/ -// \____/\___/ \__,_|\___\_____/_|\__\___| -// -// F i l e -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// (at your option) any later version. -// -////////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// - -#include "dbcontentcacher.h" -#include <wx/ffile.h> -#include <wx/xrc/xmlres.h> -#include <wx/stopwatch.h> -#include "fileutils.h" - -const wxEventType wxEVT_CMD_DB_CONTENT_CACHE_COMPLETED = XRCID("wxEVT_CMD_DB_CONTENT_CACHE_COMPLETED"); - -DbContentCacher::DbContentCacher(wxEvtHandler* parent, const wxChar* dbfilename) - : Job(parent) - , m_filename(dbfilename) -{ -} - -DbContentCacher::~DbContentCacher() {} - -void DbContentCacher::Process(wxThread* thread) -{ - wxStopWatch sw; - sw.Start(); - - wxString fileContent; - wxCSConv fontEncConv(wxFONTENCODING_ISO8859_1); - FileUtils::ReadFileContent(m_filename, fileContent, fontEncConv); - - if(m_parent) { - wxCommandEvent e(wxEVT_CMD_DB_CONTENT_CACHE_COMPLETED); - e.SetString(wxString::Format(_("Symbols file loaded into OS file system cache (%ld seconds)"), sw.Time() / 1000) - .c_str()); - m_parent->AddPendingEvent(e); - } -} diff --git a/LiteEditor/dbcontentcacher.h b/LiteEditor/dbcontentcacher.h deleted file mode 100644 index 174757b3c6..0000000000 --- a/LiteEditor/dbcontentcacher.h +++ /dev/null @@ -1,44 +0,0 @@ -////////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// -// -// copyright : (C) 2013 by Eran Ifrah -// file name : dbcontentcacher.h -// -// ------------------------------------------------------------------------- -// A -// _____ _ _ _ _ -// / __ \ | | | | (_) | -// | / \/ ___ __| | ___| | _| |_ ___ -// | | / _ \ / _ |/ _ \ | | | __/ _ ) -// | \__/\ (_) | (_| | __/ |___| | || __/ -// \____/\___/ \__,_|\___\_____/_|\__\___| -// -// F i l e -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// (at your option) any later version. -// -////////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// - -#ifndef DBCONTENTCACHER_H -#define DBCONTENTCACHER_H - -#include "job.h" // Base class: Job - -extern const wxEventType wxEVT_CMD_DB_CONTENT_CACHE_COMPLETED; - -class DbContentCacher : public Job -{ - wxString m_filename; -public: - DbContentCacher(wxEvtHandler* parent, const wxChar* dbfilename); - virtual ~DbContentCacher(); - -public: - virtual void Process(wxThread* thread); -}; - -#endif // DBCONTENTCACHER_H diff --git a/LiteEditor/frame.cpp b/LiteEditor/frame.cpp index 62aceb4f60..3e2aa4b3ae 100644 --- a/LiteEditor/frame.cpp +++ b/LiteEditor/frame.cpp @@ -98,7 +98,6 @@ #include "generalinfo.h" #include "globals.h" #include "imanager.h" -#include "jobqueue.h" #include "language.h" #include "localstable.h" #include "macros.h" @@ -117,7 +116,6 @@ #include "project.h" #include "quickdebugdlg.h" #include "quickfindbar.h" -#include "refactorindexbuildjob.h" #include "renamesymboldlg.h" #include "replaceinfilespanel.h" #include "save_perspective_as_dlg.h" @@ -751,9 +749,6 @@ clMainFrame::clMainFrame(wxWindow* pParent, wxWindowID id, const wxString& title SearchThreadST::Get()->SetNotifyWindow(EventNotifier::Get()); SearchThreadST::Get()->Start(WXTHREAD_MIN_PRIORITY); - // start the job queue - JobQueueSingleton::Instance()->Start(6); - // Create the single instance thread m_singleInstanceThread = new clSingleInstanceThread(); m_singleInstanceThread->Start(); diff --git a/LiteEditor/manager.cpp b/LiteEditor/manager.cpp index a15086e60f..0bc0d30802 100644 --- a/LiteEditor/manager.cpp +++ b/LiteEditor/manager.cpp @@ -54,7 +54,6 @@ #include "crawler_include.h" #include "ctags_manager.h" #include "custombuildrequest.h" -#include "dbcontentcacher.h" #include "debuggerasciiviewer.h" #include "debuggerconfigtool.h" #include "debuggersettings.h" @@ -71,7 +70,6 @@ #include "fileutils.h" #include "frame.h" #include "globals.h" -#include "jobqueue.h" #include "language.h" #include "localstable.h" #include "localworkspace.h" @@ -207,7 +205,6 @@ Manager::Manager(void) Bind(wxEVT_ASYNC_PROCESS_TERMINATED, &Manager::OnProcessEnd, this); Connect(wxEVT_CMD_RESTART_CODELITE, wxCommandEventHandler(Manager::OnCmdRestart), NULL, this); - Connect(wxEVT_CMD_DB_CONTENT_CACHE_COMPLETED, wxCommandEventHandler(Manager::OnDbContentCacherLoaded), NULL, this); EventNotifier::Get()->Connect(wxEVT_CMD_PROJ_SETTINGS_SAVED, clProjectSettingsEventHandler(Manager::OnProjectSettingsModified), NULL, this); @@ -262,7 +259,6 @@ Manager::~Manager(void) DbgStop(); { // wxLogNull noLog; - JobQueueSingleton::Instance()->Stop(); SearchThreadST::Get()->Stop(); } @@ -270,7 +266,6 @@ Manager::~Manager(void) PluginManager::Get()->UnLoad(); ServiceProviderManager::Get().UnregisterAll(); DebuggerMgr::Free(); - JobQueueSingleton::Release(); TagsManagerST::Free(); // it is important to release it *before* the TagsManager LanguageST::Free(); clCxxWorkspaceST::Free(); @@ -401,13 +396,6 @@ void Manager::DoSetupWorkspace(const wxString& path) // Set the encoding for the tags manager TagsManagerST::Get()->SetEncoding(EditorConfigST::Get()->GetOptions()->GetFileFontEncoding()); - // Load the tags file content (we load the file and then destroy it) this way the file is forced into - // the file system cache and will prevent hangs when first using the tagging system - if(TagsManagerST::Get()->GetDatabase()) { - wxFileName dbfn = TagsManagerST::Get()->GetDatabase()->GetDatabaseFileName(); - JobQueueSingleton::Instance()->PushJob(new DbContentCacher(this, dbfn.GetFullPath().c_str())); - } - // Ensure that the "C++" view is selected clGetManager()->GetWorkspaceView()->SelectPage(clCxxWorkspaceST::Get()->GetWorkspaceType()); } @@ -3296,8 +3284,6 @@ void Manager::OnProjectSettingsModified(clProjectSettingsEvent& event) clMainFrame::Get()->SelectBestEnvSet(); } -void Manager::OnDbContentCacherLoaded(wxCommandEvent& event) { clLogMessage(event.GetString()); } - void Manager::GetActiveProjectAndConf(wxString& project, wxString& conf) { if(!IsWorkspaceOpen()) { diff --git a/LiteEditor/manager.h b/LiteEditor/manager.h index 352e54dcbb..01e142e567 100644 --- a/LiteEditor/manager.h +++ b/LiteEditor/manager.h @@ -25,10 +25,6 @@ #ifndef MANAGER_H #define MANAGER_H -#include <list> -#include <map> -#include <wx/event.h> - #include "async_executable_cmd.h" #include "breakpointsmgr.h" #include "clDebuggerTerminal.h" @@ -43,6 +39,10 @@ #include "singleton.h" #include "workspace.h" +#include <list> +#include <map> +#include <wx/event.h> + class clEditor; class IProcess; @@ -344,12 +344,6 @@ class Manager : public wxEvtHandler, public IDebuggerObserver */ void RetagWorkspace(TagsManager::RetagType type); - /** - * @brief the parser thread has completed to scan for include files to parse - * @param event - */ - void OnDbContentCacherLoaded(wxCommandEvent& event); - /** * \brief retag a given file * \param filename diff --git a/LiteEditor/pluginmanager.cpp b/LiteEditor/pluginmanager.cpp index 985aff31c9..212e322fca 100644 --- a/LiteEditor/pluginmanager.cpp +++ b/LiteEditor/pluginmanager.cpp @@ -46,7 +46,6 @@ #include "fileview.h" #include "frame.h" #include "generalinfo.h" -#include "jobqueue.h" #include "language.h" #include "macromanager.h" #include "manager.h" @@ -449,7 +448,6 @@ wxAuiManager* PluginManager::GetDockingManager() { return m_dockingManager; } EnvironmentConfig* PluginManager::GetEnv() { return EnvironmentConfig::Instance(); } -JobQueue* PluginManager::GetJobQueue() { return JobQueueSingleton::Instance(); } wxString PluginManager::GetProjectExecutionCommand(const wxString& projectName, wxString& wd) { return ManagerST::Get()->GetProjectExecutionCommand(projectName, wd, false); diff --git a/LiteEditor/pluginmanager.h b/LiteEditor/pluginmanager.h index 0c8d6e0347..e042e006bb 100644 --- a/LiteEditor/pluginmanager.h +++ b/LiteEditor/pluginmanager.h @@ -42,7 +42,6 @@ class clToolBar; class clEditorBar; class wxBookCtrlBase; class EnvironmentConfig; -class JobQueue; class BuildSettingsConfig; class BuildManager; class BitmapLoader; @@ -110,7 +109,6 @@ class PluginManager : public IManager int GetToolbarIconSize() override; wxAuiManager* GetDockingManager() override; EnvironmentConfig* GetEnv() override; - JobQueue* GetJobQueue() override; wxString GetProjectExecutionCommand(const wxString& projectName, wxString& wd) override; wxApp* GetTheApp() override; void ReloadWorkspace() override; diff --git a/LiteEditor/refactorindexbuildjob.cpp b/LiteEditor/refactorindexbuildjob.cpp deleted file mode 100644 index 03f4621c74..0000000000 --- a/LiteEditor/refactorindexbuildjob.cpp +++ /dev/null @@ -1,82 +0,0 @@ -////////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// -// -// copyright : (C) 2008 by Eran Ifrah -// file name : refactorindexbuildjob.cpp -// -// ------------------------------------------------------------------------- -// A -// _____ _ _ _ _ -// / __ \ | | | | (_) | -// | / \/ ___ __| | ___| | _| |_ ___ -// | | / _ \ / _ |/ _ \ | | | __/ _ ) -// | \__/\ (_) | (_| | __/ |___| | || __/ -// \____/\___/ \__,_|\___\_____/_|\__\___| -// -// F i l e -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// (at your option) any later version. -// -////////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// -#include <wx/sizer.h> -#include <wx/stopwatch.h> -#include <wx/progdlg.h> -#include "cppwordscanner.h" -#include <wx/filename.h> -#include "refactorindexbuildjob.h" -#include "progress_dialog.h" -#include "workspace.h" - -//#define POST_NEW_STATUS(msg, value, act) -// status = new RefactorIndexBuildJobInfo; -// status->filename = msg; -// status->status = value; -// status->action = act; -// Post(status); - -RefactorIndexBuildJob::RefactorIndexBuildJob(const std::vector<wxFileName> &files, const wxChar *word) - : m_files( files ) - , m_word(word) -{ -} - -RefactorIndexBuildJob::~RefactorIndexBuildJob() -{ -} - -void RefactorIndexBuildJob::Parse(const wxString &word, CppTokensMap &l) -{ - clProgressDlg* prgDlg = NULL; - // Create a progress dialog - prgDlg = new clProgressDlg (NULL, _("Gathering required information..."), wxT(""), (int)m_files.size()); - prgDlg->Update(0, _("Gathering required information...")); - - size_t i=0; - for ( ; i<m_files.size(); i++) { - - wxFileName fn = m_files.at(i); - CppWordScanner scanner(fn.GetFullPath().mb_str().data()); - - wxString msg; - msg << _("Parsing: ") << fn.GetFullName(); - // update the progress bar - if (!prgDlg->Update(i, msg)){ - prgDlg->Destroy(); - l.clear(); - return; - } - - scanner.Match(word.mb_str().data(), l); - } - prgDlg->Destroy(); -} - -void RefactorIndexBuildJob::Process(wxThread* thread) -{ - CppTokensMap l; - Parse(m_word.c_str(), l); -} diff --git a/LiteEditor/refactorindexbuildjob.h b/LiteEditor/refactorindexbuildjob.h deleted file mode 100644 index 7c5ee238da..0000000000 --- a/LiteEditor/refactorindexbuildjob.h +++ /dev/null @@ -1,46 +0,0 @@ -////////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// -// -// copyright : (C) 2008 by Eran Ifrah -// file name : refactorindexbuildjob.h -// -// ------------------------------------------------------------------------- -// A -// _____ _ _ _ _ -// / __ \ | | | | (_) | -// | / \/ ___ __| | ___| | _| |_ ___ -// | | / _ \ / _ |/ _ \ | | | __/ _ ) -// | \__/\ (_) | (_| | __/ |___| | || __/ -// \____/\___/ \__,_|\___\_____/_|\__\___| -// -// F i l e -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// (at your option) any later version. -// -////////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// - #ifndef __refactorindexbuildjob__ -#define __refactorindexbuildjob__ - -#include "cpptoken.h" -#include <vector> -#include <wx/filename.h> -#include "job.h" - -class RefactorIndexBuildJob : public Job -{ - std::vector<wxFileName> m_files; - wxString m_word; - -public: - RefactorIndexBuildJob(const std::vector<wxFileName> &files, const wxChar* word); - virtual ~RefactorIndexBuildJob(); - void Process(wxThread *thread); - -public: - void Parse(const wxString &word, CppTokensMap &l); -}; -#endif // __refactorindexbuildjob__ diff --git a/LiteEditor/stringhighlighterjob.h b/LiteEditor/stringhighlighterjob.h index 696b7a2df3..3eaaa748f0 100644 --- a/LiteEditor/stringhighlighterjob.h +++ b/LiteEditor/stringhighlighterjob.h @@ -25,12 +25,11 @@ #ifndef __stringhighlighterjob__ #define __stringhighlighterjob__ -#include "job.h" #include <vector> struct StringHighlightOutput { wxString filename; - std::vector<std::pair<int, int> > matches; + std::vector<std::pair<int, int>> matches; StringHighlightOutput() : filename(wxT("")) diff --git a/Plugin/job.cpp b/Plugin/job.cpp deleted file mode 100644 index 3324016057..0000000000 --- a/Plugin/job.cpp +++ /dev/null @@ -1,54 +0,0 @@ -////////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// -// -// copyright : (C) 2008 by Eran Ifrah -// file name : job.cpp -// -// ------------------------------------------------------------------------- -// A -// _____ _ _ _ _ -// / __ \ | | | | (_) | -// | / \/ ___ __| | ___| | _| |_ ___ -// | | / _ \ / _ |/ _ \ | | | __/ _ ) -// | \__/\ (_) | (_| | __/ |___| | || __/ -// \____/\___/ \__,_|\___\_____/_|\__\___| -// -// F i l e -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// (at your option) any later version. -// -////////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// -#include "job.h" - -const wxEventType wxEVT_CMD_JOB_STATUS = wxNewEventType(); -const wxEventType wxEVT_CMD_JOB_STATUS_VOID_PTR = wxNewEventType(); - -Job::Job(wxEvtHandler* parent) - : m_parent(parent) -{ -} - -Job::~Job() {} - -void Job::Post(int i, const wxString& message) -{ - if(m_parent) { - wxCommandEvent e(wxEVT_CMD_JOB_STATUS); - e.SetInt(i); - e.SetString(message); - m_parent->AddPendingEvent(e); - } -} - -void Job::Post(void* ptr) -{ - if(m_parent) { - wxCommandEvent e(wxEVT_CMD_JOB_STATUS_VOID_PTR); - e.SetClientData(ptr); - m_parent->AddPendingEvent(e); - } -} diff --git a/Plugin/job.h b/Plugin/job.h deleted file mode 100644 index aa7589f828..0000000000 --- a/Plugin/job.h +++ /dev/null @@ -1,79 +0,0 @@ -////////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// -// -// copyright : (C) 2008 by Eran Ifrah -// file name : job.h -// -// ------------------------------------------------------------------------- -// A -// _____ _ _ _ _ -// / __ \ | | | | (_) | -// | / \/ ___ __| | ___| | _| |_ ___ -// | | / _ \ / _ |/ _ \ | | | __/ _ ) -// | \__/\ (_) | (_| | __/ |___| | || __/ -// \____/\___/ \__,_|\___\_____/_|\__\___| -// -// F i l e -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// (at your option) any later version. -// -////////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// -#ifndef __job__ -#define __job__ - -#include "codelite_exports.h" - -#include <wx/event.h> - -extern WXDLLIMPEXP_SDK const wxEventType wxEVT_CMD_JOB_STATUS; -extern WXDLLIMPEXP_SDK const wxEventType wxEVT_CMD_JOB_STATUS_VOID_PTR; - -/** - * \class Job - * \author Eran - * \date 05/09/08 - * \file job.h - * \brief this class defines the interface to a job used by the JobQueue - * To use the JobQueue, you should inherit from Job, and implement the Porcess() pure virtual function - */ -class WXDLLIMPEXP_SDK Job -{ -protected: - wxEvtHandler* m_parent; - -public: - /** - * @brief Construct Job object with optional parent event handler. - * @param parent event handler class which would like to receive notifications of progress - */ - Job(wxEvtHandler* parent = NULL); - virtual ~Job(); - -public: - /** - * @brief post string and int values to parent in a form of wxCommandEvent of type wxEVT_CMD_JOB_STATUS. the string - * can be accessed by using event.GetString() and the int by calling event.GetInt(). this function has no affect if - * parnet is NULL - * @param i - * @param message - */ - void Post(int i, const wxString& message); - /** - * @brief post void* to parent in a form of wxCommandEvent of type wxEVT_CMD_JOB_STATUS_VOID_PTR. the void* can be - * accessed by using event.GetClientData() method. NB: User must free the void* this function has no affect if - * parnet is NULL - * @param i integer to send to parent - */ - virtual void Post(void* ptr); - /** - * @brief overridable Process() method. If the Process() method is performs a long computations, it is advised to - * to call thread->TestDestroy() to allow the thread to exit when requested - * @param thread the thread that is currently running the job. - */ - virtual void Process(wxThread* thread) = 0; -}; -#endif // __job__ diff --git a/Plugin/jobqueue.cpp b/Plugin/jobqueue.cpp deleted file mode 100644 index 1142b972bc..0000000000 --- a/Plugin/jobqueue.cpp +++ /dev/null @@ -1,136 +0,0 @@ -////////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// -// -// copyright : (C) 2008 by Eran Ifrah -// file name : jobqueue.cpp -// -// ------------------------------------------------------------------------- -// A -// _____ _ _ _ _ -// / __ \ | | | | (_) | -// | / \/ ___ __| | ___| | _| |_ ___ -// | | / _ \ / _ |/ _ \ | | | __/ _ ) -// | \__/\ (_) | (_| | __/ |___| | || __/ -// \____/\___/ \__,_|\___\_____/_|\__\___| -// -// F i l e -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// (at your option) any later version. -// -////////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// -#include "jobqueue.h" - -#include "job.h" - -JobQueueWorker::JobQueueWorker(wxMessageQueue<Job*>* queue) - : wxThread(wxTHREAD_JOINABLE) - , m_queue(queue) -{ -} - -JobQueueWorker::~JobQueueWorker() {} -void JobQueueWorker::Stop() -{ - if(IsAlive()) { - Delete(NULL, wxTHREAD_WAIT_BLOCK); - - } else { - Wait(wxTHREAD_WAIT_BLOCK); - } -} - -void JobQueueWorker::Start(int priority) -{ - Create(); - SetPriority(priority); - Run(); -} - -void* JobQueueWorker::Entry() -{ - while(!TestDestroy()) { - Job* job(NULL); - if((m_queue->ReceiveTimeout(50, job) == wxMSGQUEUE_NO_ERROR) && job) { - - // Call user's implementation for processing request - ProcessJob(job); - - wxThread::Sleep(10); // Allow other threads to work as well - delete job; - job = NULL; - continue; // to avoid the sleep - } - } - return NULL; -} - -void JobQueueWorker::ProcessJob(Job* job) -{ - if(job) { - job->Process(this); - } -} - -//-------------------------------------------------------------- -// JobQueue -//-------------------------------------------------------------- - -JobQueue::JobQueue() {} - -JobQueue::~JobQueue() -{ - // Clear the queue and release it memory - Job* pJob(NULL); - while(m_queue.ReceiveTimeout(1, pJob) == wxMSGQUEUE_NO_ERROR) { - wxDELETE(pJob); - } -} - -void JobQueue::PushJob(Job* job) { m_queue.Post(job); } - -void JobQueue::Start(size_t poolSize, int priority) -{ - size_t maxPoolSize = poolSize > 250 ? 250 : poolSize; - for(size_t i = 0; i < maxPoolSize; i++) { - // create new thread - JobQueueWorker* worker = new JobQueueWorker(&m_queue); - worker->Start(priority); - m_threads.push_back(worker); - } -} - -void JobQueue::Stop() -{ - // first loop and stop all running threads - for(size_t i = 0; i < m_threads.size(); i++) { - JobQueueWorker* worker = m_threads.at(i); - // stop it - worker->Stop(); - // delete it - delete worker; - } - m_threads.clear(); -} - -//----------------------------------------------------- -// Job queue singleton -//----------------------------------------------------- -JobQueue* JobQueueSingleton::ms_instance = new JobQueue(); - -JobQueueSingleton::JobQueueSingleton() {} - -JobQueueSingleton::~JobQueueSingleton() {} - -JobQueue* JobQueueSingleton::Instance() { return ms_instance; } - -void JobQueueSingleton::Release() -{ - if(ms_instance) { - delete ms_instance; - } - ms_instance = 0; -} diff --git a/Plugin/jobqueue.h b/Plugin/jobqueue.h deleted file mode 100644 index c5fbf01bf7..0000000000 --- a/Plugin/jobqueue.h +++ /dev/null @@ -1,166 +0,0 @@ -////////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// -// -// copyright : (C) 2008 by Eran Ifrah -// file name : jobqueue.h -// -// ------------------------------------------------------------------------- -// A -// _____ _ _ _ _ -// / __ \ | | | | (_) | -// | / \/ ___ __| | ___| | _| |_ ___ -// | | / _ \ / _ |/ _ \ | | | __/ _ ) -// | \__/\ (_) | (_| | __/ |___| | || __/ -// \____/\___/ \__,_|\___\_____/_|\__\___| -// -// F i l e -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// (at your option) any later version. -// -////////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// -#ifndef __jobqueue__ -#define __jobqueue__ - -#include "codelite_exports.h" - -#include <deque> -#include <vector> -#include <wx/msgqueue.h> -#include <wx/thread.h> - -class Job; - -/** - * @class JobQueueWorker - * @author Eran - * @date 05/09/08 - * @file jobqueue.h - * @brief a thread class used internally by JobQueue - * @sa JobQueue - */ -class WXDLLIMPEXP_SDK JobQueueWorker : public wxThread -{ - wxMessageQueue<Job*>* m_queue; - -public: - /// default ctor/dtor - JobQueueWorker(wxMessageQueue<Job*>* queue); - virtual ~JobQueueWorker(); - -private: - // declare this class as non copyable - JobQueueWorker(const JobQueueWorker& rhs); - JobQueueWorker& operator=(const JobQueueWorker& rhs); - -public: - /** - * @brief stop the running thread. usually called before calling JobQueue::Release() - */ - void Stop(); - - /** - * @brief start the thread with given priority - * @param priority thread priority (defaulted to WXTHREAD_DEFAULT_PRIORITY) - */ - void Start(int priority = WXTHREAD_DEFAULT_PRIORITY); - - /** - * @brief implementation of the wxThread pure virtual function Entry() - * @sa wxThread - */ - virtual void* Entry(); - - /** - * @brief the main code that processes the job - * @param job job to process - * @sa Job - */ - virtual void ProcessJob(Job* job); -}; - -/** - * @class JobQueue - * @author Eran - * @date 05/09/08 - * @file jobqueue.h - * @brief this class provides a convenient way of handling background tasks using Job objects - * - * @code - * // somewhere in your application initialization - * // start the job queue with 5 workers and default thread prioritization - * m_jobQueue = new JobQueue(); - * m_jobQueue->Start(5); - * - * // whenever you need to add new job to be processed - * // just add it - * m_jobQueue->PushJob( new MyJob() ); - * - * // Shutdown code: - * m_jobQueue->Stop(); - * // free the resources allocated by the JobQueue and empty the queue - * delete m_jobQueue; - * @endcode - * - */ -class JobQueue -{ - wxMessageQueue<Job*> m_queue; - std::vector<JobQueueWorker*> m_threads; - -public: - JobQueue(); - virtual ~JobQueue(); - - /** - * @brief add job to the queue. all jobs must be constructed on the heap. - * note that the job will be freed when processing is done by the job queue - * @param job job to process allocated on the heap - */ - virtual void PushJob(Job* job); - - /** - * @brief - * @param poolSize - * @param priority - */ - virtual void Start(size_t poolSize = 1, int priority = WXTHREAD_DEFAULT_PRIORITY); - - /** - * @brief stop all workers threads - */ - virtual void Stop(); -}; - -/** - * @class JobQueueSingleton - * @author Eran - * @date 05/09/08 - * @file jobqueue.h - * @brief a wrapper around the JobQueue class that provides the functionality of singleton - */ -class WXDLLIMPEXP_SDK JobQueueSingleton -{ -private: - static JobQueue* ms_instance; - -private: - JobQueueSingleton(); - virtual ~JobQueueSingleton(); - -public: - /** - * @brief - * @return - */ - static JobQueue* Instance(); - - /** - * @brief - */ - static void Release(); -}; -#endif // __jobqueue__ diff --git a/codelitephp/PHPParser/PHPSymbolsCacher.cpp b/codelitephp/PHPParser/PHPSymbolsCacher.cpp deleted file mode 100644 index 1c3d76cd96..0000000000 --- a/codelitephp/PHPParser/PHPSymbolsCacher.cpp +++ /dev/null @@ -1,29 +0,0 @@ -#include "PHPSymbolsCacher.h" -#include <wx/ffile.h> -#include <wx/stopwatch.h> -#include "php_code_completion.h" - -PHPSymbolsCacher::PHPSymbolsCacher(PHPCodeCompletion* owner, const wxString& dbfile) - : m_owner(owner) - , m_filename(dbfile) -{ -} - -PHPSymbolsCacher::~PHPSymbolsCacher() {} - -void PHPSymbolsCacher::Process(wxThread* thread) -{ - wxStopWatch sw; - sw.Start(); - - wxFFile dbFile(m_filename, "rb"); - if(dbFile.IsOpened()) { - wxString fileContent; - wxCSConv fontEncConv(wxFONTENCODING_ISO8859_1); - dbFile.ReadAll(&fileContent, fontEncConv); - dbFile.Close(); - m_owner->CallAfter(&PHPCodeCompletion::OnSymbolsCached); - } else { - m_owner->CallAfter(&PHPCodeCompletion::OnSymbolsCacheError); - } -} diff --git a/codelitephp/PHPParser/PHPSymbolsCacher.h b/codelitephp/PHPParser/PHPSymbolsCacher.h deleted file mode 100644 index 4310397813..0000000000 --- a/codelitephp/PHPParser/PHPSymbolsCacher.h +++ /dev/null @@ -1,47 +0,0 @@ -////////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// -// -// Copyright : (C) 2015 Eran Ifrah -// File name : PHPSymbolsCacher.h -// -// ------------------------------------------------------------------------- -// A -// _____ _ _ _ _ -// / __ \ | | | | (_) | -// | / \/ ___ __| | ___| | _| |_ ___ -// | | / _ \ / _ |/ _ \ | | | __/ _ ) -// | \__/\ (_) | (_| | __/ |___| | || __/ -// \____/\___/ \__,_|\___\_____/_|\__\___| -// -// F i l e -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// (at your option) any later version. -// -////////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// - -#ifndef PHPSYMBOLSCACHER_H -#define PHPSYMBOLSCACHER_H - -#include "job.h" // Base class: Job -#include <wx/string.h> -#include <wx/event.h> - -class PHPCodeCompletion; -class PHPSymbolsCacher : public Job -{ - PHPCodeCompletion* m_owner; - wxString m_filename; - -public: - PHPSymbolsCacher(PHPCodeCompletion* owner, const wxString& dbfile); - virtual ~PHPSymbolsCacher(); - -public: - virtual void Process(wxThread* thread); -}; - -#endif // PHPSYMBOLSCACHER_H diff --git a/codelitephp/PHPParser/php_code_completion.cpp b/codelitephp/PHPParser/php_code_completion.cpp index 74b49eb605..9826933647 100644 --- a/codelitephp/PHPParser/php_code_completion.cpp +++ b/codelitephp/PHPParser/php_code_completion.cpp @@ -10,14 +10,12 @@ #include "PHPEntityKeyword.h" #include "PHPEntityVariable.h" #include "PHPExpression.h" -#include "PHPSymbolsCacher.h" #include "clEditorBar.h" #include "clSelectSymbolDialog.h" #include "cl_command_event.h" #include "cl_config.h" #include "editor_config.h" #include "globals.h" -#include "jobqueue.h" #include "macros.h" #include "php_helpers.h" #include "php_parser_thread.h" @@ -595,7 +593,6 @@ void PHPCodeCompletion::Open(const wxFileName& workspaceFile) // then closing it wxFileName fnDBFile(workspaceFile.GetPath(), "phpsymbols.db"); fnDBFile.AppendDir(".codelite"); - JobQueueSingleton::Instance()->PushJob(new PHPSymbolsCacher(this, fnDBFile.GetFullPath())); } void PHPCodeCompletion::Close() diff --git a/cppchecker/cppcheck_settings.h b/cppchecker/cppcheck_settings.h index e3c9690fe2..56c37eed47 100644 --- a/cppchecker/cppcheck_settings.h +++ b/cppchecker/cppcheck_settings.h @@ -26,10 +26,9 @@ #ifndef __cppcheckjob__ #define __cppcheckjob__ -#include "job.h" -#include "serialized_object.h" -#include "project.h" #include "macros.h" +#include "project.h" +#include "serialized_object.h" // Define the events needed by this job extern const wxEventType wxEVT_CPPCHECKJOB_STATUS_MESSAGE; diff --git a/cppchecker/cppchecker.cpp b/cppchecker/cppchecker.cpp index 21da8957ad..e5346a9b32 100644 --- a/cppchecker/cppchecker.cpp +++ b/cppchecker/cppchecker.cpp @@ -35,7 +35,6 @@ #include "fileextmanager.h" #include "globals.h" #include "imanager.h" -#include "jobqueue.h" #include "macros.h" #include "processreaderthread.h" #include "procutils.h"