THRIFT-3397 Implement TProcessorFactory in C# to enable per-client processors
Client: C#
Patch: Jonathan Heard
This closes #663
diff --git a/lib/csharp/src/Server/TThreadPoolServer.cs b/lib/csharp/src/Server/TThreadPoolServer.cs
index 4c201e9..f0c7fe4 100644
--- a/lib/csharp/src/Server/TThreadPoolServer.cs
+++ b/lib/csharp/src/Server/TThreadPoolServer.cs
@@ -38,7 +38,7 @@
private volatile bool stop = false;
public TThreadPoolServer(TProcessor processor, TServerTransport serverTransport)
- : this(processor, serverTransport,
+ : this(new TSingletonProcessorFactory(processor), serverTransport,
new TTransportFactory(), new TTransportFactory(),
new TBinaryProtocol.Factory(), new TBinaryProtocol.Factory(),
DEFAULT_MIN_THREADS, DEFAULT_MAX_THREADS, DefaultLogDelegate)
@@ -46,33 +46,43 @@
}
public TThreadPoolServer(TProcessor processor, TServerTransport serverTransport, LogDelegate logDelegate)
- : this(processor, serverTransport,
+ : this(new TSingletonProcessorFactory(processor), serverTransport,
new TTransportFactory(), new TTransportFactory(),
new TBinaryProtocol.Factory(), new TBinaryProtocol.Factory(),
DEFAULT_MIN_THREADS, DEFAULT_MAX_THREADS, logDelegate)
{
}
-
public TThreadPoolServer(TProcessor processor,
+ TServerTransport serverTransport,
+ TTransportFactory transportFactory,
+ TProtocolFactory protocolFactory)
+ : this(new TSingletonProcessorFactory(processor), serverTransport,
+ transportFactory, transportFactory,
+ protocolFactory, protocolFactory,
+ DEFAULT_MIN_THREADS, DEFAULT_MAX_THREADS, DefaultLogDelegate)
+ {
+ }
+
+ public TThreadPoolServer(TProcessorFactory processorFactory,
TServerTransport serverTransport,
TTransportFactory transportFactory,
TProtocolFactory protocolFactory)
- : this(processor, serverTransport,
+ : this(processorFactory, serverTransport,
transportFactory, transportFactory,
protocolFactory, protocolFactory,
DEFAULT_MIN_THREADS, DEFAULT_MAX_THREADS, DefaultLogDelegate)
{
}
- public TThreadPoolServer(TProcessor processor,
+ public TThreadPoolServer(TProcessorFactory processorFactory,
TServerTransport serverTransport,
TTransportFactory inputTransportFactory,
TTransportFactory outputTransportFactory,
TProtocolFactory inputProtocolFactory,
TProtocolFactory outputProtocolFactory,
int minThreadPoolThreads, int maxThreadPoolThreads, LogDelegate logDel)
- : base(processor, serverTransport, inputTransportFactory, outputTransportFactory,
+ : base(processorFactory, serverTransport, inputTransportFactory, outputTransportFactory,
inputProtocolFactory, outputProtocolFactory, logDel)
{
lock (typeof(TThreadPoolServer))
@@ -149,6 +159,7 @@
private void Execute(Object threadContext)
{
TTransport client = (TTransport)threadContext;
+ TProcessor processor = processorFactory.GetProcessor(client, this);
TTransport inputTransport = null;
TTransport outputTransport = null;
TProtocol inputProtocol = null;