r1361@opsdev009 (orig r71612): mcslee | 2007-11-27 17:51:43 -0800
[amiethrift.git] / lib / cpp / src / server / TSimpleServer.h
blob1ab6f073dcaed8ebbac7b797cdff054d2382cd6b
1 // Copyright (c) 2006- Facebook
2 // Distributed under the Thrift Software License
3 //
4 // See accompanying file LICENSE or visit the Thrift site at:
5 // http://developers.facebook.com/thrift/
7 #ifndef _THRIFT_SERVER_TSIMPLESERVER_H_
8 #define _THRIFT_SERVER_TSIMPLESERVER_H_ 1
10 #include "server/TServer.h"
11 #include "transport/TServerTransport.h"
13 namespace facebook { namespace thrift { namespace server {
15 /**
16 * This is the most basic simple server. It is single-threaded and runs a
17 * continuous loop of accepting a single connection, processing requests on
18 * that connection until it closes, and then repeating. It is a good example
19 * of how to extend the TServer interface.
21 * @author Mark Slee <mcslee@facebook.com>
23 class TSimpleServer : public TServer {
24 public:
25 TSimpleServer(boost::shared_ptr<TProcessor> processor,
26 boost::shared_ptr<TServerTransport> serverTransport,
27 boost::shared_ptr<TTransportFactory> transportFactory,
28 boost::shared_ptr<TProtocolFactory> protocolFactory) :
29 TServer(processor, serverTransport, transportFactory, protocolFactory),
30 stop_(false) {}
32 TSimpleServer(boost::shared_ptr<TProcessor> processor,
33 boost::shared_ptr<TServerTransport> serverTransport,
34 boost::shared_ptr<TTransportFactory> inputTransportFactory,
35 boost::shared_ptr<TTransportFactory> outputTransportFactory,
36 boost::shared_ptr<TProtocolFactory> inputProtocolFactory,
37 boost::shared_ptr<TProtocolFactory> outputProtocolFactory):
38 TServer(processor, serverTransport,
39 inputTransportFactory, outputTransportFactory,
40 inputProtocolFactory, outputProtocolFactory),
41 stop_(false) {}
43 ~TSimpleServer() {}
45 void serve();
47 void stop() {
48 stop_ = true;
51 protected:
52 bool stop_;
56 }}} // facebook::thrift::server
58 #endif // #ifndef _THRIFT_SERVER_TSIMPLESERVER_H_