X-Git-Url: https://git.dogcows.com/gitweb?p=chaz%2Fyoink;a=blobdiff_plain;f=src%2FMoof%2FThread.hh;fp=src%2FMoof%2FThread.hh;h=3e0bd829a8affabd059f5b7b376779e7971e4fbf;hp=52a878a553d68ebf26d33320dfebb2494a9af457;hb=41f8dd670e963aad94527ce2be0486268993a477;hpb=40755d4c6251206c18ce4784967d3a910cee096f diff --git a/src/Moof/Thread.hh b/src/Moof/Thread.hh index 52a878a..3e0bd82 100644 --- a/src/Moof/Thread.hh +++ b/src/Moof/Thread.hh @@ -23,6 +23,7 @@ namespace Mf { + // // The detach function detaches a separate thread by calling 'func' with // the 'arg' parameter. @@ -80,6 +81,41 @@ inline unsigned getThreadIdentifier(Thread thread) } +class AsyncTask +{ +public: + + virtual ~AsyncTask() {} + + virtual bool isDone() const = 0; + + virtual void run() = 0; + virtual int wait() = 0; +}; + +class ThreadedTask +{ +public: + + ThreadedTask() : + mThread(0) {} + + Thread thread() const { return mThread; } + + int wait() + { + int code = waitOnThread(mThread); + mThread = 0; + return code; + } + + +protected: + + Thread mThread; +}; + + //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ class Mutex