Changeset 4948 in ntrip
- Timestamp:
- Feb 23, 2013, 4:56:07 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GnssCenter/thrift/test2/server.cpp
r4947 r4948 7 7 #include <thrift/transport/TBufferTransports.h> 8 8 #include <thrift/concurrency/Thread.h> 9 #include <thrift/concurrency/PosixThreadFactory.h> 9 10 10 11 #include "gen-cpp/myService.h" … … 12 13 using namespace std; 13 14 using namespace boost; 14 using namespace ::apache::thrift;15 using namespace ::apache::thrift::protocol;16 using namespace ::apache::thrift::transport;17 using namespace ::apache::thrift::server;18 using namespace ::apache::thrift::concurrency;15 using namespace apache::thrift; 16 using namespace apache::thrift::protocol; 17 using namespace apache::thrift::transport; 18 using namespace apache::thrift::server; 19 using namespace apache::thrift::concurrency; 19 20 20 21 class myService : virtual public myServiceIf { … … 45 46 cout << "connection " << endl; 46 47 47 shared_ptr<t_connection> connection(new t_connection);48 connection->_service = service;49 connection->_processor = processor;50 connection->_protocolInp = info.input;51 connection->_protocolOut = info.output;52 connection->_transport = info.transport;48 CONNECTION.reset(new t_connection); 49 CONNECTION->_service = service; 50 CONNECTION->_processor = processor; 51 CONNECTION->_protocolInp = info.input; 52 CONNECTION->_protocolOut = info.output; 53 CONNECTION->_transport = info.transport; 53 54 54 55 return processor; … … 56 57 }; 57 58 58 class t_serverThread : public Runnable {59 class t_serverThread : public apache::thrift::concurrency::Runnable { 59 60 public: 60 61 t_serverThread() {} 62 ~t_serverThread() {} 61 63 void run() { 62 64 int port = 9090; … … 69 71 transportFactory, protocolFactory); 70 72 server.serve(); 71 } 73 } 72 74 }; 73 75 74 76 int main(int argc, char **argv) { 75 77 76 t_serverThread serverThread; 77 serverThread.run(); 78 shared_ptr<PosixThreadFactory> threadFactory(new PosixThreadFactory); 79 80 shared_ptr<t_serverThread> serverThread(new t_serverThread); 81 82 shared_ptr<Thread> thread = threadFactory->newThread(serverThread); 83 thread->start(); 84 85 cout << "server thread started" << endl; 78 86 79 87 while (true) { 88 cout << "sleep ..." << endl; 80 89 sleep(1); 81 90 }
Note:
See TracChangeset
for help on using the changeset viewer.