diff thread/Thread.h @ 67:516c86946900

* Pull out AsynchronousTask into its own header * Add a fixed-size block allocator based on FSBAllocator
author cannam
date Thu, 14 May 2009 12:45:08 +0000
parents 2af6edd98dfa
children 5f88f517b637
line wrap: on
line diff
--- a/thread/Thread.h	Wed May 13 17:41:10 2009 +0000
+++ b/thread/Thread.h	Thu May 14 12:45:08 2009 +0000
@@ -146,65 +146,4 @@
 #endif
 };
 
-class AsynchronousTask : public Thread
-{
-public:
-    AsynchronousTask() :
-        m_todo("AsynchronousTask: task to perform"),
-        m_done("AsynchronousTask: task complete"),
-        m_inTask(false),
-        m_finishing(false)
-    {
-        start();
-    }
-    virtual ~AsynchronousTask()
-    {
-        m_finishing = true;
-        m_todo.signal();
-        wait();
-    }
-
-    // subclass must provide methods to request task and obtain
-    // results
-
-protected:
-    void startTask() {
-        m_todo.lock();
-        m_inTask = true;
-        m_todo.signal();
-        m_done.lock();
-        m_todo.unlock();
-    }
-    void awaitTask() {
-        while (m_inTask) m_done.wait();
-        m_done.unlock();
-    }
-
-    virtual void performTask() = 0;
-    
-private:
-    virtual void run() {
-        m_todo.lock();
-        while (!m_finishing) {
-            while (!m_inTask && !m_finishing) {
-                m_todo.wait();
-            }
-            if (m_finishing) {
-                break;
-            }
-            if (m_inTask) {
-                performTask();
-                m_inTask = false;
-                m_done.signal();
-            }
-        }
-        m_todo.unlock();
-    }
-
-    Condition m_todo;
-    Condition m_done;
-    bool m_inTask;
-    bool m_finishing;
-};
-
 #endif