[Assorted-commits] SF.net SVN: assorted:[1099] cpp-commons/trunk/src/commons/st/st.h
Brought to you by:
yangzhang
From: <yan...@us...> - 2008-12-11 21:21:19
|
Revision: 1099 http://assorted.svn.sourceforge.net/assorted/?rev=1099&view=rev Author: yangzhang Date: 2008-12-11 21:21:13 +0000 (Thu, 11 Dec 2008) Log Message: ----------- - added st_multichannel - fixed namespace issues Modified Paths: -------------- cpp-commons/trunk/src/commons/st/st.h Modified: cpp-commons/trunk/src/commons/st/st.h =================================================================== --- cpp-commons/trunk/src/commons/st/st.h 2008-12-11 19:16:31 UTC (rev 1098) +++ cpp-commons/trunk/src/commons/st/st.h 2008-12-11 21:21:13 UTC (rev 1099) @@ -20,6 +20,7 @@ namespace commons { using namespace boost; + using namespace std; enum { default_stack_size = 65536 }; @@ -239,6 +240,28 @@ }; /** + * An unbounded FIFO multi-cast channel, i.e. publish-subscribe. + * \todo Use shared_ptr. + */ + template <typename T> + class st_multichannel + { + public: + void push(const T &x) { + foreach (st_channel<T> *q, qs) { + q->push(x); + } + } + st_channel<T> &subscribe() { + st_channel<T>* q = new st_channel<T>; + qs.push_back(q); + return *q; + } + private: + vector<st_channel<T>*> qs; + }; + + /** * A hub is a single point to signal to wake up a set of threads. Threads * join the hub before calling a blocking operation if they want to make * themselves interruptible on this hub. @@ -266,7 +289,7 @@ threads.clear(); } private: - set<st_thread_t> threads; + std::set<st_thread_t> threads; }; /** @@ -366,7 +389,7 @@ } void insert(st_thread_t t) { ts.insert(t); } private: - set<st_thread_t> ts; + std::set<st_thread_t> ts; }; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |