blob: 98ecde0f47d6b5edf864667aaad7ffab455a4d15 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
|
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
#ifndef _THRIFT_TRANSPORT_TSERVERWINPIPES_H_
#define _THRIFT_TRANSPORT_TSERVERWINPIPES_H_ 1
#include <thrift/transport/TServerTransport.h>
#include <boost/shared_ptr.hpp>
#ifndef _WIN32
# include <thrift/transport/TServerSocket.h>
#endif
#ifdef _WIN32
# include <thrift/windows/Sync.h>
#endif
#define TPIPE_SERVER_MAX_CONNS_DEFAULT PIPE_UNLIMITED_INSTANCES
namespace apache { namespace thrift { namespace transport {
/**
* Windows Pipes implementation of TServerTransport.
* Don't destroy a TPipeServer at global scope, as that will cause a thread join
* during DLLMain. That also means that TServer's using TPipeServer shouldn't be at global
* scope.
*/
#ifdef _WIN32
class TPipeServerImpl;
class TPipe;
class TPipeServer : public TServerTransport {
public:
//Constructors
// Named Pipe -
TPipeServer(const std::string &pipename, uint32_t bufsize);
TPipeServer(const std::string &pipename, uint32_t bufsize, uint32_t maxconnections);
TPipeServer(const std::string &pipename);
// Anonymous pipe -
TPipeServer(int bufsize);
TPipeServer();
//Destructor
virtual ~TPipeServer();
//Standard transport callbacks
virtual void interrupt();
virtual void close();
virtual void listen();
//Accessors
std::string getPipename();
void setPipename(const std::string &pipename);
int getBufferSize();
void setBufferSize(int bufsize);
HANDLE getPipeHandle(); //Named Pipe R/W -or- Anonymous pipe Read handle
HANDLE getWrtPipeHandle();
HANDLE getClientRdPipeHandle();
HANDLE getClientWrtPipeHandle();
bool getAnonymous();
void setAnonymous(bool anon);
void setMaxConnections(uint32_t maxconnections);
//this function is intended to be used in generic / template situations,
//so its name needs to be the same as TPipe's
HANDLE getNativeWaitHandle();
protected:
virtual boost::shared_ptr<TTransport> acceptImpl();
private:
boost::shared_ptr<TPipeServerImpl> impl_;
std::string pipename_;
uint32_t bufsize_;
uint32_t maxconns_;
bool isAnonymous_;
};
#else //_WIN32
//*NIX named pipe implementation uses domain socket
typedef TServerSocket TPipeServer;
#endif
}}} // apache::thrift::transport
#endif // #ifndef _THRIFT_TRANSPORT_TSERVERWINPIPES_H_
|