Rev 1319 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed
| Rev 1319 | Rev 1403 | ||
|---|---|---|---|
| Line 14... | Line 14... | ||
| 14 | #include <boost/signal.hpp> |
14 | #include <boost/signal.hpp> |
| 15 | #include <boost/thread.hpp> |
15 | #include <boost/thread.hpp> |
| 16 | #include <boost/thread/mutex.hpp> |
16 | #include <boost/thread/mutex.hpp> |
| 17 | #include <boost/thread/condition.hpp> |
17 | #include <boost/thread/condition.hpp> |
| 18 | #include <boost/thread/locks.hpp> |
18 | #include <boost/thread/locks.hpp> |
| 19 | #include "Broker.h" |
- | |
| 20 | #include "message/Message.h" |
19 | #include "message/Message.h" |
| 21 | #include "log/Logger.h" |
20 | #include "log/Logger.h" |
| 22 | #include "thread/Thread.h" |
21 | #include "thread/Thread.h" |
| 23 | #include "thread/Queue.hpp" |
22 | #include "thread/Queue.hpp" |
| 24 | #include <boost/make_shared.hpp> |
23 | #include <boost/make_shared.hpp> |
| 25 | 24 | ||
| 26 | namespace atom { |
25 | namespace atom { |
| 27 | namespace broker { |
- | |
| 28 | 26 | ||
| 29 | using namespace message; |
27 | using namespace message; |
| 30 | 28 | ||
| 31 | class Subscriber : public boost::signals::trackable, public thread::Thread |
29 | class Subscriber : public boost::signals::trackable, public thread::Thread |
| 32 | { |
30 | { |
| 33 | typedef boost::mutex::scoped_lock lock; |
- | |
| 34 | - | ||
| 35 | public: |
31 | public: |
| 36 | typedef boost::shared_ptr<Subscriber> |
32 | typedef boost::shared_ptr<Subscriber> Pointer; |
| 37 | 33 | ||
| 38 | Subscriber( |
34 | Subscriber(bool receive_from_self); |
| 39 | virtual ~Subscriber(); |
35 | virtual ~Subscriber(); |
| 40 | 36 | ||
| 41 | protected: |
37 | protected: |
| 42 |
|
38 | void PutMessage(Message::pointer message); |
| - | 39 | Message::pointer CreateMessage() const; |
|
| 43 | 40 | ||
| 44 | void put(Message::pointer message); |
- | |
| 45 | virtual void |
41 | virtual void OnMessage(Message::pointer message) = 0; |
| 46 | 42 | ||
| 47 | private: |
43 | private: |
| 48 | log::Logger LOG; |
44 | log::Logger LOG; |
| 49 | thread::Queue<Message::pointer> myQueue; |
- | |
| 50 | bool myReceiveFromMyself; |
- | |
| 51 | boost::condition myCondition; |
- | |
| 52 | boost::mutex myMutex; |
- | |
| 53 | 45 | ||
| - | 46 | thread::Queue<Message::pointer> queue_; |
|
| - | 47 | bool receive_from_self_; |
|
| - | 48 | ||
| - | 49 | boost::condition on_message_condition_; |
|
| - | 50 | boost::mutex guard_mutex_; |
|
| - | 51 | ||
| 54 | void |
52 | void Slot_OnMessage(Message::pointer message); |
| - | 53 | ||
| 55 | void |
54 | void Run(); |
| 56 | }; |
55 | }; |
| 57 | 56 | ||
| 58 | } |
57 | } |
| 59 | } |
58 | } |
| 60 | 59 | ||