blob: be8f4f2e094a527cf84189ec0e61831204fda2f8 [file] [log] [blame]
Mark Slee9f0c6512007-02-28 23:58:26 +00001// 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/
6
Mark Sleed788b2e2006-09-07 01:26:35 +00007#ifndef _THRIFT_SERVER_TSIMPLESERVER_H_
8#define _THRIFT_SERVER_TSIMPLESERVER_H_ 1
Mark Sleee8540632006-05-30 09:24:40 +00009
10#include "server/TServer.h"
11#include "transport/TServerTransport.h"
12
T Jake Lucianib5e62212009-01-31 22:36:20 +000013namespace apache { namespace thrift { namespace server {
Marc Slemko6f038a72006-08-03 18:58:09 +000014
Mark Sleee8540632006-05-30 09:24:40 +000015/**
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.
20 *
Mark Sleee8540632006-05-30 09:24:40 +000021 */
22class TSimpleServer : public TServer {
23 public:
Mark Slee5ea15f92007-03-05 22:55:59 +000024 TSimpleServer(boost::shared_ptr<TProcessor> processor,
25 boost::shared_ptr<TServerTransport> serverTransport,
26 boost::shared_ptr<TTransportFactory> transportFactory,
27 boost::shared_ptr<TProtocolFactory> protocolFactory) :
Mark Slee6e3f6372007-03-01 22:05:46 +000028 TServer(processor, serverTransport, transportFactory, protocolFactory),
29 stop_(false) {}
Aditya Agarwal9abb0d62007-01-24 22:53:54 +000030
Mark Slee5ea15f92007-03-05 22:55:59 +000031 TSimpleServer(boost::shared_ptr<TProcessor> processor,
32 boost::shared_ptr<TServerTransport> serverTransport,
33 boost::shared_ptr<TTransportFactory> inputTransportFactory,
34 boost::shared_ptr<TTransportFactory> outputTransportFactory,
35 boost::shared_ptr<TProtocolFactory> inputProtocolFactory,
36 boost::shared_ptr<TProtocolFactory> outputProtocolFactory):
Mark Sleeb4d3e7b2007-11-28 01:51:43 +000037 TServer(processor, serverTransport,
Aditya Agarwal9abb0d62007-01-24 22:53:54 +000038 inputTransportFactory, outputTransportFactory,
Mark Slee6e3f6372007-03-01 22:05:46 +000039 inputProtocolFactory, outputProtocolFactory),
40 stop_(false) {}
Mark Sleeb4d3e7b2007-11-28 01:51:43 +000041
Mark Sleee8540632006-05-30 09:24:40 +000042 ~TSimpleServer() {}
43
Mark Slee794993d2006-09-20 01:56:10 +000044 void serve();
Mark Sleee8540632006-05-30 09:24:40 +000045
Mark Slee6e3f6372007-03-01 22:05:46 +000046 void stop() {
47 stop_ = true;
48 }
49
50 protected:
51 bool stop_;
52
Mark Sleee8540632006-05-30 09:24:40 +000053};
54
T Jake Lucianib5e62212009-01-31 22:36:20 +000055}}} // apache::thrift::server
Marc Slemko6f038a72006-08-03 18:58:09 +000056
Mark Sleed788b2e2006-09-07 01:26:35 +000057#endif // #ifndef _THRIFT_SERVER_TSIMPLESERVER_H_