source: ntrip/trunk/GnssCenter/thrift/rtnet_sdo_example/ConnectionStatusMonitor.h@ 5032

Last change on this file since 5032 was 4941, checked in by mervart, 12 years ago
File size: 1.6 KB
RevLine 
[4941]1#ifndef RTNET_SDO_EXAMPLE_CONNECTIONSTATUSMONITOR_H
2#define RTNET_SDO_EXAMPLE_CONNECTIONSTATUSMONITOR_H
3
4#include <transport/TTransport.h>
5#include <concurrency/TimerManager.h>
6
7#include <set>
8//#include <cstdatomic> // needs newer version of g++ using C++0x
9#include <boost/detail/atomic_count.hpp>
10
11class ConnectionRequiredRunnable;
12
13class ConnectionStatusMonitor
14{
15public:
16 ConnectionStatusMonitor(boost::shared_ptr<apache::thrift::transport::TTransport>& transport,
17 boost::shared_ptr<apache::thrift::concurrency::TimerManager>& timeMgr);
18 ~ConnectionStatusMonitor();
19
20 void addListener(boost::shared_ptr<ConnectionRequiredRunnable> listener);
21 void disconnected(const ConnectionRequiredRunnable* noticer);
22 void tryOpen();
23 void stop();
24 bool connected();
25
26private:
27 class Reconnect : public apache::thrift::concurrency::Runnable
28 {
29 public:
30 Reconnect(ConnectionStatusMonitor* parent) : parent_(parent) {}
31 void run() {
32 parent_->tryOpen();
33 }
34 private:
35 ConnectionStatusMonitor* parent_;
36 };
37 std::set<boost::shared_ptr<ConnectionRequiredRunnable> > listeners_;
38 boost::shared_ptr<apache::thrift::transport::TTransport> transport_;
39 boost::shared_ptr<apache::thrift::concurrency::TimerManager> timeMgr_;
40 boost::shared_ptr<apache::thrift::concurrency::ThreadFactory> thFactory_;
41 //std::atomic<bool> connected_;
42 //boost::atomic<bool> connected_; // need a higher version of boost or gcc than is available on kurenai
43 boost::detail::atomic_count connected_; // need a higher version of boost or gcc than is available on kurenai
44};
45
46#endif // RTNET_SDO_EXAMPLE_CONNECTIONSTATUSMONITOR_H
Note: See TracBrowser for help on using the repository browser.