Hello,
I'm writing a multi-threaded non-blocking Thrift client application. Each
thread will uses its own Thrift connection.
I'm not clear what is required for a non-blocking thread safe client
connection. Does every thread have to create the following four values: socket,
transport, protocol, client? Like this:
shared_ptr<TTransport> socket(new TSocket("localhost", 9090));
shared_ptr<TTransport> transport(new TBufferedTransport(socket));
shared_ptr<TProtocol> protocol(new TBinaryProtocol(transport));
MyThriftClient client(protocol);
And then:
transport->open();
client.ping();
transport->close();
*OR*
Can one or more values be safely shared between threads? For example:
socket?
Also, in the above example the thread calls transport->close();
Can open/close be replaced with just an open when the thread is created and
leave it open() even when the thread is in the pool (sleeping)?
TIA!
Adam.