Skip to content

Commit

Permalink
Delegated a few communication task to background jobs
Browse files Browse the repository at this point in the history
  • Loading branch information
gunterkoenigsmann committed Jan 21, 2024
1 parent 2d938c5 commit a8deb78
Show file tree
Hide file tree
Showing 36 changed files with 494 additions and 718 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/compile_ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ jobs:
run: |
cd build
export HOME=`pwd`
export CTEST_PARALLEL_LEVEL=1
export CTEST_PARALLEL_LEVEL=3
export CTEST_OUTPUT_ON_FAILURE=1
xvfb-run -a ctest
cd ..
Expand Down Expand Up @@ -90,7 +90,7 @@ jobs:
run: |
cd build
export HOME=`pwd`
export CTEST_PARALLEL_LEVEL=1
export CTEST_PARALLEL_LEVEL=3
export CTEST_OUTPUT_ON_FAILURE=1
xvfb-run -a ctest
cd ..
Expand Down
21 changes: 17 additions & 4 deletions src/Autocomplete.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,18 +91,31 @@ void AutoComplete::AddSymbols(wxString xml) {
wxLogMessage(_("Scheduling a background task that compiles a new list "
"of autocompletable maxima commands."));

wxString sharedir = m_configuration->MaximaShareDir();
sharedir.Replace("\n", "");
sharedir.Replace("\r", "");
m_addSymbols_backgroundThread = std::thread(&AutoComplete::AddSymbols_Backgroundtask_string,
this, std::move(xml));
}

void AutoComplete::AddSymbols(wxXmlDocument xml) {
if(m_addSymbols_backgroundThread.joinable())
{
wxLogMessage(_("Waiting for m_addSymbols_backgroundThread to finish"));
m_addSymbols_backgroundThread.join();
}
wxLogMessage(_("Scheduling a background task that compiles a new list "
"of autocompletable maxima commands."));

m_addSymbols_backgroundThread = std::thread(&AutoComplete::AddSymbols_Backgroundtask,
this, std::move(xml));
}

void AutoComplete::AddSymbols_Backgroundtask(wxString xml) {
void AutoComplete::AddSymbols_Backgroundtask_string(wxString xml) {
wxXmlDocument xmldoc;
wxStringInputStream xmlStream(xml);
xmldoc.Load(xmlStream, wxS("UTF-8"));
AddSymbols_Backgroundtask(xmldoc);
}

void AutoComplete::AddSymbols_Backgroundtask(wxXmlDocument xmldoc) {
wxXmlNode *node = xmldoc.GetRoot();
if (node != NULL) {
wxXmlNode *children = node->GetChildren();
Expand Down
10 changes: 8 additions & 2 deletions src/Autocomplete.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#include <memory>
#include <mutex>
#include <wx/wx.h>
#include <wx/xml/xml.h>
#include <wx/event.h>
#include <wx/dir.h>
#include <vector>
Expand Down Expand Up @@ -75,7 +76,7 @@ class AutoComplete : public wxEvtHandler
explicit AutoComplete(Configuration *configuration);

//! The destructor of AutoComplete
~AutoComplete();
virtual ~AutoComplete();

//! Load all autocomplete symbols wxMaxima knows about by itself
void LoadSymbols();
Expand All @@ -92,8 +93,13 @@ class AutoComplete : public wxEvtHandler
void AddSymbol(wxString fun, autoCompletionType type = command);
//! Interprets the XML autocompletable symbol list maxima can send us
void AddSymbols(wxString xml);
//! Interprets the XML autocompletable symbol list maxima can send us
void AddSymbols(wxXmlDocument xml);
//! The real work of AddSymbols is made here and in the background
void AddSymbols_Backgroundtask_string(wxString xml);
//! The real work of AddSymbols is made here and in the background
void AddSymbols_Backgroundtask(wxString xml);
void AddSymbols_Backgroundtask(wxXmlDocument xmldoc);


//! Replace the list of files in the directory the worksheet file is in to the demo files list
void UpdateDemoFiles(wxString partial, wxString maximaDir);
Expand Down
2 changes: 1 addition & 1 deletion src/AutocompletePopup.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class AutocompletePopup final : public wxListView, public wxComboPopup
void SetPosition(wxPoint pos){m_position = pos;}
//! Create popup control
bool Create(wxWindow* parent) override;
~AutocompletePopup();
virtual ~AutocompletePopup();
//! Gets the info which keycode the current keypress results in
void OnChar(wxKeyEvent &event);
//! Gets the info which key has been pressed with which modifier
Expand Down
2 changes: 1 addition & 1 deletion src/BTextCtrl.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class BTextCtrl : public wxTextCtrl
const wxSize &size = wxDefaultSize,
long style = 0);

~BTextCtrl();
virtual ~BTextCtrl();

void SetSkipTab(bool skip)
{
Expand Down
2 changes: 1 addition & 1 deletion src/CompositeDataObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class CompositeDataObject final : public wxDataObject
{
public:
CompositeDataObject();
~CompositeDataObject() override;
virtual ~CompositeDataObject() override;

void Add(wxDataObject *object, bool preferred = false);
wxDataObject *GetObject(const wxDataFormat& format,
Expand Down
6 changes: 3 additions & 3 deletions src/Configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ class Configuration
//! Get the brush to be used for worksheet objects that provide a mouse-over tooltip
wxBrush GetTooltipBrush() const {return m_tooltipBrush;}

~Configuration();
virtual ~Configuration();

/*! Where to store the configuration.
Expand Down Expand Up @@ -1262,7 +1262,7 @@ class Printing
m_configuration = configuration;
m_configuration->SetPrinting(true);
}
~Printing()
virtual ~Printing()
{
m_configuration->SetPrinting(false);
}
Expand All @@ -1279,7 +1279,7 @@ class NoClipToDrawRegion
m_configuration = configuration;
m_configuration->ClipToDrawRegion(false);
}
~NoClipToDrawRegion()
virtual ~NoClipToDrawRegion()
{
m_configuration->ClipToDrawRegion(true);
}
Expand Down
4 changes: 2 additions & 2 deletions src/ErrorRedirector.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class ErrorRedirector : public wxLog
explicit ErrorRedirector(std::unique_ptr<wxLog> &&newLog);

//! Restores the previous log target
~ErrorRedirector() override;
virtual ~ErrorRedirector() override;

/*! This method is called from the idle loop.
Expand Down Expand Up @@ -112,7 +112,7 @@ class SuppressErrorDialogs
{
public:
SuppressErrorDialogs(){ErrorRedirector::m_messages_logPaneOnly++;}
~SuppressErrorDialogs(){ErrorRedirector::m_messages_logPaneOnly--;}
virtual ~SuppressErrorDialogs(){ErrorRedirector::m_messages_logPaneOnly--;}
};

#endif // ERRORREDIRECTOR_H
2 changes: 1 addition & 1 deletion src/EvaluationQueue.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ class EvaluationQueue
m_commands.back().AddEnding();
}

~EvaluationQueue()
virtual ~EvaluationQueue()
{};

//! Is GroupCell gr part of the evaluation queue?
Expand Down
4 changes: 2 additions & 2 deletions src/Image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ Image::Image(Configuration *config, const Image &image) {
}

Image::~Image() {
SuppressErrorDialogs logNull;
wxLogNull logNull;
if(m_loadImageTask.joinable())
m_loadImageTask.join();
if(m_loadGnuplotSourceTask.joinable())
Expand Down Expand Up @@ -801,7 +801,7 @@ void Image::LoadImage_Backgroundtask(std::unique_ptr<ThreadNumberLimiter> limite

file.Close();
if (ok && remove) {
SuppressErrorDialogs suppressor;
wxLogNull suppressor;
if(!wxRemoveFile(image))
{
wxMilliSleep(300);
Expand Down
2 changes: 1 addition & 1 deletion src/Image.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ class Image final
Image(Configuration *config, const Image &image);
Image(const Image &image) = delete;

~Image();
virtual ~Image();

//! Converts rgba data to a wxBitmap
static wxBitmap RGBA2wxBitmap(const unsigned char imgdata[],
Expand Down
2 changes: 1 addition & 1 deletion src/MathParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class MathParser
MathParser(const MathParser&) = delete;
//! This class doesn't have a = operator
MathParser& operator=(const MathParser&) = delete;
~MathParser();
virtual ~MathParser();

void SetUserLabel(wxString label){ m_userDefinedLabel = label; }
/***
Expand Down
Loading

0 comments on commit a8deb78

Please sign in to comment.