Rev 1315 | Rev 1318 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed
| Rev 1315 | Rev 1317 | ||
|---|---|---|---|
| Line 17... | Line 17... | ||
| 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" |
19 | #include "Broker.h" |
| 20 | #include "message/Message.h" |
20 | #include "message/Message.h" |
| 21 | #include "log/Logger.h" |
21 | #include "log/Logger.h" |
| 22 | #include " |
22 | #include "thread/Thread.h" |
| 23 | #include " |
23 | #include "thread/Queue.h" |
| 24 | #include <boost/make_shared.hpp> |
24 | #include <boost/make_shared.hpp> |
| 25 | 25 | ||
| 26 | namespace atom { |
26 | namespace atom { |
| 27 | namespace broker { |
27 | namespace broker { |
| 28 | 28 | ||
| 29 | using namespace utils; |
29 | using namespace utils; |
| 30 | using namespace message; |
30 | using namespace message; |
| 31 | 31 | ||
| 32 | class Subscriber : public boost::signals::trackable, public |
32 | class Subscriber : public boost::signals::trackable, public thread::Thread |
| 33 | { |
33 | { |
| 34 | typedef boost::mutex::scoped_lock lock; |
34 | typedef boost::mutex::scoped_lock lock; |
| 35 | 35 | ||
| 36 | public: |
36 | public: |
| 37 | typedef boost::shared_ptr<Subscriber> pointer; |
37 | typedef boost::shared_ptr<Subscriber> pointer; |
| Line 45... | Line 45... | ||
| 45 | void put(Message::pointer message); |
45 | void put(Message::pointer message); |
| 46 | virtual void onNewMessage(Message::pointer message); |
46 | virtual void onNewMessage(Message::pointer message); |
| 47 | 47 | ||
| 48 | private: |
48 | private: |
| 49 | log::Logger LOG; |
49 | log::Logger LOG; |
| 50 |
|
50 | thread::Queue<Message::pointer> myQueue; |
| 51 | bool myReceiveFromMyself; |
51 | bool myReceiveFromMyself; |
| 52 | boost::condition myCondition; |
52 | boost::condition myCondition; |
| 53 | boost::mutex myMutex; |
53 | boost::mutex myMutex; |
| 54 | 54 | ||
| 55 | void newMessageHandler(Message::pointer message); |
55 | void newMessageHandler(Message::pointer message); |