More boosification of thrift driver, server, transport and protocol code
Modified TestServer to use thread-pool manager
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@664737 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/lib/cpp/src/protocol/TBinaryProtocol.cc b/lib/cpp/src/protocol/TBinaryProtocol.cc
index ed482b8..fef8ab4 100644
--- a/lib/cpp/src/protocol/TBinaryProtocol.cc
+++ b/lib/cpp/src/protocol/TBinaryProtocol.cc
@@ -3,16 +3,28 @@
namespace facebook { namespace thrift { namespace protocol {
-uint32_t TBinaryProtocol::writeStructBegin(TTransport* out,
+uint32_t TBinaryProtocol::writeMessageBegin(shared_ptr<TTransport> out,
+ const TMessageType messageType,
+ const uint32_t seqid) const {
+ return
+ writeByte(out, (uint8_t)messageType) +
+ writeU32(out, seqid);
+}
+
+uint32_t TBinaryProtocol::writeMessageEnd(shared_ptr<TTransport> out) const {
+ return 0;
+}
+
+uint32_t TBinaryProtocol::writeStructBegin(shared_ptr<TTransport> out,
const string& name) const {
return 0;
}
-uint32_t TBinaryProtocol::writeStructEnd(TTransport* out) const {
+uint32_t TBinaryProtocol::writeStructEnd(shared_ptr<TTransport> out) const {
return 0;
}
-uint32_t TBinaryProtocol::writeFieldBegin(TTransport* out,
+uint32_t TBinaryProtocol::writeFieldBegin(shared_ptr<TTransport> out,
const string& name,
const TType fieldType,
const uint16_t fieldId) const {
@@ -21,16 +33,16 @@
writeI32(out, (int32_t)fieldId);
}
-uint32_t TBinaryProtocol::writeFieldEnd(TTransport* out) const {
+uint32_t TBinaryProtocol::writeFieldEnd(shared_ptr<TTransport> out) const {
return 0;
}
-uint32_t TBinaryProtocol::writeFieldStop(TTransport* out) const {
+uint32_t TBinaryProtocol::writeFieldStop(shared_ptr<TTransport> out) const {
return
writeByte(out, (uint8_t)T_STOP);
}
-uint32_t TBinaryProtocol::writeMapBegin(TTransport* out,
+uint32_t TBinaryProtocol::writeMapBegin(shared_ptr<TTransport> out,
const TType keyType,
const TType valType,
const int32_t size) const {
@@ -40,11 +52,11 @@
writeI32(out, (int32_t)size);
}
-uint32_t TBinaryProtocol::writeMapEnd(TTransport* out) const {
+uint32_t TBinaryProtocol::writeMapEnd(shared_ptr<TTransport> out) const {
return 0;
}
-uint32_t TBinaryProtocol::writeListBegin(TTransport* out,
+uint32_t TBinaryProtocol::writeListBegin(shared_ptr<TTransport> out,
const TType elemType,
const int32_t size) const {
return
@@ -52,11 +64,11 @@
writeI32(out, (int32_t)size);
}
-uint32_t TBinaryProtocol::writeListEnd(TTransport* out) const {
+uint32_t TBinaryProtocol::writeListEnd(shared_ptr<TTransport> out) const {
return 0;
}
-uint32_t TBinaryProtocol::writeSetBegin(TTransport* out,
+uint32_t TBinaryProtocol::writeSetBegin(shared_ptr<TTransport> out,
const TType elemType,
const int32_t size) const {
return
@@ -64,45 +76,45 @@
writeI32(out, (int32_t)size);
}
-uint32_t TBinaryProtocol::writeSetEnd(TTransport* out) const {
+uint32_t TBinaryProtocol::writeSetEnd(shared_ptr<TTransport> out) const {
return 0;
}
-uint32_t TBinaryProtocol::writeByte(TTransport* out,
+uint32_t TBinaryProtocol::writeByte(shared_ptr<TTransport> out,
const uint8_t byte) const {
out->write(&byte, 1);
return 1;
}
-uint32_t TBinaryProtocol::writeU32(TTransport* out,
+uint32_t TBinaryProtocol::writeU32(shared_ptr<TTransport> out,
const uint32_t u32) const {
uint32_t net = (uint32_t)htonl(u32);
out->write((uint8_t*)&net, 4);
return 4;
}
-uint32_t TBinaryProtocol::writeI32(TTransport* out,
+uint32_t TBinaryProtocol::writeI32(shared_ptr<TTransport> out,
const int32_t i32) const {
int32_t net = (int32_t)htonl(i32);
out->write((uint8_t*)&net, 4);
return 4;
}
-uint32_t TBinaryProtocol::writeU64(TTransport* out,
+uint32_t TBinaryProtocol::writeU64(shared_ptr<TTransport> out,
const uint64_t u64) const {
uint64_t net = (uint64_t)htonll(u64);
out->write((uint8_t*)&net, 8);
return 8;
}
-uint32_t TBinaryProtocol::writeI64(TTransport* out,
+uint32_t TBinaryProtocol::writeI64(shared_ptr<TTransport> out,
const int64_t i64) const {
int64_t net = (int64_t)htonll(i64);
out->write((uint8_t*)&net, 8);
return 8;
}
-uint32_t TBinaryProtocol::writeString(TTransport* out,
+uint32_t TBinaryProtocol::writeString(shared_ptr<TTransport> out,
const string& str) const {
uint32_t result = writeI32(out, str.size());
out->write((uint8_t*)str.data(), str.size());
@@ -113,17 +125,33 @@
* Reading functions
*/
-uint32_t TBinaryProtocol::readStructBegin(TTransport* in,
+uint32_t TBinaryProtocol::readMessasgeBegin(shared_ptr<TTransport> in,
+ TMessageType& messageType,
+ uint32_t& seqid) const {
+
+ uint32_t result = 0;
+ uint8_t type;
+ result+= readByte(in, type);
+ messageType = (TMessageType)type;
+ result+= readU32(in, seqid);
+ return result;
+}
+
+uint32_t TBinaryProtocol::readMessageEnd(shared_ptr<TTransport> in) const{
+ return 0;
+}
+
+uint32_t TBinaryProtocol::readStructBegin(shared_ptr<TTransport> in,
string& name) const {
name = "";
return 0;
}
-uint32_t TBinaryProtocol::readStructEnd(TTransport* in) const {
+uint32_t TBinaryProtocol::readStructEnd(shared_ptr<TTransport> in) const {
return 0;
}
-uint32_t TBinaryProtocol::readFieldBegin(TTransport* in,
+uint32_t TBinaryProtocol::readFieldBegin(shared_ptr<TTransport> in,
string& name,
TType& fieldType,
uint16_t& fieldId) const {
@@ -141,11 +169,11 @@
return result;
}
-uint32_t TBinaryProtocol::readFieldEnd(TTransport* in) const {
+uint32_t TBinaryProtocol::readFieldEnd(shared_ptr<TTransport> in) const {
return 0;
}
-uint32_t TBinaryProtocol::readMapBegin(TTransport* in,
+uint32_t TBinaryProtocol::readMapBegin(shared_ptr<TTransport> in,
TType& keyType,
TType& valType,
int32_t& size) const {
@@ -159,11 +187,11 @@
return result;
}
-uint32_t TBinaryProtocol::readMapEnd(TTransport* in) const {
+uint32_t TBinaryProtocol::readMapEnd(shared_ptr<TTransport> in) const {
return 0;
}
-uint32_t TBinaryProtocol::readListBegin(TTransport* in,
+uint32_t TBinaryProtocol::readListBegin(shared_ptr<TTransport> in,
TType& elemType,
int32_t& size) const {
uint8_t e;
@@ -174,11 +202,11 @@
return result;
}
-uint32_t TBinaryProtocol::readListEnd(TTransport* in) const {
+uint32_t TBinaryProtocol::readListEnd(shared_ptr<TTransport> in) const {
return 0;
}
-uint32_t TBinaryProtocol::readSetBegin(TTransport* in,
+uint32_t TBinaryProtocol::readSetBegin(shared_ptr<TTransport> in,
TType& elemType,
int32_t& size) const {
uint8_t e;
@@ -189,11 +217,11 @@
return result;
}
-uint32_t TBinaryProtocol::readSetEnd(TTransport* in) const {
+uint32_t TBinaryProtocol::readSetEnd(shared_ptr<TTransport> in) const {
return 0;
}
-uint32_t TBinaryProtocol::readByte(TTransport* in,
+uint32_t TBinaryProtocol::readByte(shared_ptr<TTransport> in,
uint8_t& byte) const {
uint8_t b[1];
in->readAll(b, 1);
@@ -201,7 +229,7 @@
return 1;
}
-uint32_t TBinaryProtocol::readU32(TTransport* in,
+uint32_t TBinaryProtocol::readU32(shared_ptr<TTransport> in,
uint32_t& u32) const {
uint8_t b[4];
in->readAll(b, 4);
@@ -210,7 +238,7 @@
return 4;
}
-uint32_t TBinaryProtocol::readI32(TTransport* in,
+uint32_t TBinaryProtocol::readI32(shared_ptr<TTransport> in,
int32_t& i32) const {
uint8_t b[4];
in->readAll(b, 4);
@@ -219,7 +247,7 @@
return 4;
}
-uint32_t TBinaryProtocol::readU64(TTransport* in,
+uint32_t TBinaryProtocol::readU64(shared_ptr<TTransport> in,
uint64_t& u64) const {
uint8_t b[8];
in->readAll(b, 8);
@@ -228,7 +256,7 @@
return 8;
}
-uint32_t TBinaryProtocol::readI64(TTransport* in,
+uint32_t TBinaryProtocol::readI64(shared_ptr<TTransport> in,
int64_t& i64) const {
uint8_t b[8];
in->readAll(b, 8);
@@ -237,7 +265,7 @@
return 8;
}
-uint32_t TBinaryProtocol::readString(TTransport* in,
+uint32_t TBinaryProtocol::readString(shared_ptr<TTransport> in,
string& str) const {
uint32_t result;
int32_t size;