[asterisk-scf-commits] asterisk-scf/integration/ice-util-cpp.git branch "workqueue" updated.

Commits to the Asterisk SCF project code repositories asterisk-scf-commits at lists.digium.com
Thu Apr 7 18:46:03 CDT 2011


branch "workqueue" has been updated
       via  3b4d359bcd39dbe88535a89b0f19a8368fcb205a (commit)
      from  782ecd7fa52a89e4116c9cbb9c75675e5316bc33 (commit)

Summary of changes:
 ThreadPool/include/AsteriskSCF/WorkerThread.h |   87 +++++++++++++++++++++++++
 1 files changed, 87 insertions(+), 0 deletions(-)
 create mode 100644 ThreadPool/include/AsteriskSCF/WorkerThread.h


- Log -----------------------------------------------------------------
commit 3b4d359bcd39dbe88535a89b0f19a8368fcb205a
Author: Mark Michelson <mmichelson at digium.com>
Date:   Thu Apr 7 18:45:35 2011 -0500

    Hm, forgot to add this file...

diff --git a/ThreadPool/include/AsteriskSCF/WorkerThread.h b/ThreadPool/include/AsteriskSCF/WorkerThread.h
new file mode 100644
index 0000000..5fa9150
--- /dev/null
+++ b/ThreadPool/include/AsteriskSCF/WorkerThread.h
@@ -0,0 +1,87 @@
+/*
+ * Asterisk SCF -- An open-source communications framework.
+ *
+ * Copyright (C) 2011, Digium, Inc.
+ *
+ * See http://www.asterisk.org for more information about
+ * the Asterisk SCF project. Please do not directly contact
+ * any of the maintainers of this project for assistance;
+ * the project provides a web site, mailing lists and IRC
+ * channels for your use.
+ *
+ * This program is free software, distributed under the terms of
+ * the GNU General Public License Version 2. See the LICENSE.txt file
+ * at the top of the source tree.
+ */
+#pragma once
+
+#include <boost/shared_ptr.hpp>
+
+#include <AsteriskSCF/System/ThreadPool/ThreadPoolIf.h>
+#include <AsteriskSCF/System/WorkQueue/WorkQueueIf.h>
+
+namespace AsteriskSCF
+{
+namespace ThreadPool
+{
+
+enum ThreadState
+{
+    /**
+     * Actively doing work
+     */
+    Active,
+    /**
+     * Nothing to do; waiting to be poked
+     */
+    Idle,
+    /**
+     * Marked for deletion. May still be executing
+     * code but next time it checks its state, it
+     * will die.
+     *
+     * Basically what happens when we try to kill
+     * a thread when it is Active
+     */
+    Zombie,
+    /**
+     * The ThreadPoolImpl considers this thread to
+     * be gone. The thread just needs to get out of
+     * the way ASAP.
+     *
+     * Basically what happens when we try to kill
+     * a thread when it is Idle
+     */
+    Dead
+};
+
+class WorkerThreadListener;
+
+class WorkerThread
+{
+public:
+    WorkerThread(int id, const AsteriskSCF::System::WorkQueue::V1::QueuePtr& workQueue, WorkerThreadListener *listener);
+    void poke(ThreadState newState);
+    void join();
+
+private:
+    void active();
+    void idle();
+
+    ThreadState mState;
+    WorkerThreadListener *mListener;
+    AsteriskSCF::System::WorkQueue::V1::QueuePtr mQueue;
+    boost::condition_variable mCond;
+    boost::mutex mLock;
+    boost::thread mThread;
+};
+
+class WorkerThreadListener
+{
+public:
+    virtual void activeThreadIdle(WorkerThread *thread) = 0;
+    virtual void zombieThreadDead(WorkerThread *thread) = 0;
+};
+
+}; // end namespace ThreadPool
+}; // end namespace AsteriskSCF

-----------------------------------------------------------------------


-- 
asterisk-scf/integration/ice-util-cpp.git



More information about the asterisk-scf-commits mailing list