Changeset 4948 in ntrip


Ignore:
Timestamp:
Feb 23, 2013, 4:56:07 PM (12 years ago)
Author:
mervart
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/GnssCenter/thrift/test2/server.cpp

    r4947 r4948  
    77#include <thrift/transport/TBufferTransports.h>
    88#include <thrift/concurrency/Thread.h>
     9#include <thrift/concurrency/PosixThreadFactory.h>
    910
    1011#include "gen-cpp/myService.h"
     
    1213using namespace std;
    1314using 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;
     15using namespace apache::thrift;
     16using namespace apache::thrift::protocol;
     17using namespace apache::thrift::transport;
     18using namespace apache::thrift::server;
     19using namespace apache::thrift::concurrency;
    1920
    2021class myService : virtual public myServiceIf {
     
    4546    cout << "connection " << endl;
    4647
    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;
    5354   
    5455    return processor;
     
    5657};
    5758
    58 class t_serverThread : public Runnable {
     59class t_serverThread : public apache::thrift::concurrency::Runnable {
    5960 public:
    6061  t_serverThread() {}
     62  ~t_serverThread() {}
    6163  void run() {
    6264    int port = 9090;
     
    6971                           transportFactory, protocolFactory);
    7072    server.serve();
    71   }
     73  }   
    7274};
    7375
    7476int main(int argc, char **argv) {
    7577
    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;
    7886
    7987  while (true) {
     88    cout << "sleep ..." << endl;
    8089    sleep(1);
    8190  }
Note: See TracChangeset for help on using the changeset viewer.