X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;ds=sidebyside;f=src%2FMoof%2FThread.hh;h=3e0bd829a8affabd059f5b7b376779e7971e4fbf;hb=1a9061caa8fe73b4b34a37fe467e145bba7bd2f5;hp=52a878a553d68ebf26d33320dfebb2494a9af457;hpb=837bae9f2bf7b25e1d3d2625eeaf39c1d2f48827;p=chaz%2Fyoink 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