summaryrefslogtreecommitdiff
path: root/library/multithreading.h
blob: 21c5bcf28cb5a6e11e178fa7466b6009a6b2d0c7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#ifndef MULTITHREADING_H_INCLUDED
#define MULTITHREADING_H_INCLUDED

#include <wx/thread.h>

class StatusHandler;
class WorkerThread;


//class handling execution of a method while updating the UI
class UpdateWhileExecuting
{
    friend class WorkerThread;

public:
    UpdateWhileExecuting();

    virtual ~UpdateWhileExecuting();

    void waitUntilReady();
    void execute(StatusHandler* statusUpdater);


private:
    //implement a longrunning method without dependencies (e.g. copy file function); share input/output parameters as instance variables
    virtual void longRunner() = 0;

    WorkerThread* theWorkerThread;

    wxMutex     readyToReceiveResult;
    wxCondition receivingResult;
    bool workDone; //workaround for a bug in wxWidgets v2.8.9 class wxCondition: signals might get lost
};

#endif // MULTITHREADING_H_INCLUDED
bgstack15