summaryrefslogtreecommitdiff
path: root/library/multithreading.h
diff options
context:
space:
mode:
authorDaniel Wilhelm <daniel@wili.li>2014-04-18 16:54:32 +0200
committerDaniel Wilhelm <daniel@wili.li>2014-04-18 16:54:32 +0200
commitcbb59ba3fb48fb87065469eaa1b4a34a18851b9e (patch)
tree6f43ab99e0f22a33fccb941ab0441d1bee38adf9 /library/multithreading.h
parent1.11 (diff)
downloadFreeFileSync-cbb59ba3fb48fb87065469eaa1b4a34a18851b9e.tar.gz
FreeFileSync-cbb59ba3fb48fb87065469eaa1b4a34a18851b9e.tar.bz2
FreeFileSync-cbb59ba3fb48fb87065469eaa1b4a34a18851b9e.zip
1.12
Diffstat (limited to 'library/multithreading.h')
-rw-r--r--library/multithreading.h52
1 files changed, 2 insertions, 50 deletions
diff --git a/library/multithreading.h b/library/multithreading.h
index 161fd687..68ad7492 100644
--- a/library/multithreading.h
+++ b/library/multithreading.h
@@ -1,55 +1,7 @@
#ifndef MULTITHREADING_H_INCLUDED
#define MULTITHREADING_H_INCLUDED
-#include <wx/string.h>
-#include <wx/thread.h>
-
-const int UI_UPDATE_INTERVAL = 100; //perform ui updates not more often than necessary, 100 seems to be a good value with only a minimal performance loss
-
-bool updateUiIsAllowed(); //test if a specific amount of time is over
-void updateUiNow(); //do the updating
-
-
-//interface for status updates (can be implemented by UI or commandline)
-//overwrite virtual methods for respective functionality
-class StatusUpdater
-{
-public:
- StatusUpdater() :
- abortionRequested(false) {}
- virtual ~StatusUpdater() {}
-
- //these methods have to be implemented in the derived classes to handle error and status information
- virtual void updateStatusText(const wxString& text) = 0;
- virtual void initNewProcess(int objectsTotal, double dataTotal, int processID) = 0; //informs about the total amount of data that will be processed from now on
- virtual void updateProcessedData(int objectsProcessed, double dataProcessed) = 0; //called periodically after data was processed
- virtual int reportError(const wxString& text) = 0;
-
- //this method is triggered repeatedly by requestUiRefresh() and can be used to refresh the ui by dispatching pending events
- virtual void forceUiRefresh() = 0;
- void requestUiRefresh(bool asyncProcessActive = false)
- {
- if (updateUiIsAllowed()) //test if specific time span between ui updates is over
- forceUiRefresh();
-
- if (abortionRequested && !asyncProcessActive)
- abortThisProcess(); //abort can be triggered by requestAbortion()
- }
-
- void requestAbortion() //opportunity to abort must be implemented in a frequently executed method like requestUiRefresh()
- { //currently used by the UI status information screen, when button "Abort is pressed"
- abortionRequested = true;
- }
-
- static const int continueNext = -1;
- static const int retry = -2;
-
-protected:
- virtual void abortThisProcess() = 0;
-
- bool abortionRequested;
-};
-
+#include "statusHandler.h"
class WorkerThread;
@@ -65,7 +17,7 @@ public:
virtual ~UpdateWhileExecuting();
void waitUntilReady();
- void execute(StatusUpdater* statusUpdater);
+ void execute(StatusHandler* statusUpdater);
private:
bgstack15