diff options
Diffstat (limited to 'cpp')
-rw-r--r-- | cpp/demo/Ice/throughput/Client.cpp | 5 | ||||
-rw-r--r-- | cpp/demo/Ice/throughput/Throughput.ice | 4 | ||||
-rw-r--r-- | cpp/demo/Ice/throughput/ThroughputI.h | 20 | ||||
-rw-r--r-- | cpp/include/Ice/Buffer.h | 6 | ||||
-rw-r--r-- | cpp/src/Ice/BasicStream.cpp | 27 |
5 files changed, 50 insertions, 12 deletions
diff --git a/cpp/demo/Ice/throughput/Client.cpp b/cpp/demo/Ice/throughput/Client.cpp index 004b290464f..674314eb1d3 100644 --- a/cpp/demo/Ice/throughput/Client.cpp +++ b/cpp/demo/Ice/throughput/Client.cpp @@ -43,11 +43,10 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) IceUtil::Time tsec = IceUtil::Time::now(); const int repetitions = 100; - const int size = 500000; - cout << "sending and receiving " << repetitions << " sequences of size " << size + cout << "sending and receiving " << repetitions << " sequences of size " << seqSize << " (this may take a while)" << endl; - ByteSeq seq(size, 0); + ByteSeq seq(seqSize, 0); for(int i = 0; i < repetitions; ++i) { throughput->echoByteSeq(seq); diff --git a/cpp/demo/Ice/throughput/Throughput.ice b/cpp/demo/Ice/throughput/Throughput.ice index 9bf392474a1..e28cef29cf4 100644 --- a/cpp/demo/Ice/throughput/Throughput.ice +++ b/cpp/demo/Ice/throughput/Throughput.ice @@ -15,10 +15,14 @@ #ifndef THROUGHPUT_ICE #define THROUGHPUT_ICE +const int seqSize = 500000; + sequence<byte> ByteSeq; interface Throughput { + void sendByteSeq(ByteSeq seq); + ByteSeq recvByteSeq(); ByteSeq echoByteSeq(ByteSeq seq); }; diff --git a/cpp/demo/Ice/throughput/ThroughputI.h b/cpp/demo/Ice/throughput/ThroughputI.h index dcac368ff54..3326f6979b1 100644 --- a/cpp/demo/Ice/throughput/ThroughputI.h +++ b/cpp/demo/Ice/throughput/ThroughputI.h @@ -22,11 +22,31 @@ class ThroughputI : public Throughput { public: + ThroughputI() : + _seq(seqSize, 0) + { + } + + virtual void + sendByteSeq(const ByteSeq&, const Ice::Current&) + { + } + + virtual ByteSeq + recvByteSeq(const Ice::Current&) + { + return _seq; + } + virtual ByteSeq echoByteSeq(const ByteSeq& seq, const Ice::Current&) { return seq; } + +private: + + ByteSeq _seq; }; #endif diff --git a/cpp/include/Ice/Buffer.h b/cpp/include/Ice/Buffer.h index 9538795dd8d..e4df1724921 100644 --- a/cpp/include/Ice/Buffer.h +++ b/cpp/include/Ice/Buffer.h @@ -24,12 +24,6 @@ class ICE_API Buffer : public ::IceUtil::noncopyable { public: - Buffer() - { - b.reserve(1000); - i = b.begin(); - } - typedef std::vector<Ice::Byte> Container; Container b; Container::iterator i; diff --git a/cpp/src/Ice/BasicStream.cpp b/cpp/src/Ice/BasicStream.cpp index 6c578c74f8f..01b36c3e244 100644 --- a/cpp/src/Ice/BasicStream.cpp +++ b/cpp/src/Ice/BasicStream.cpp @@ -31,7 +31,6 @@ copy(InputIter first, InputIter last, OutputIter result) std::copy(first, last, result); } -/* template<> void copy(std::vector<Ice::Byte>::const_iterator first, std::vector<Ice::Byte>::const_iterator last, @@ -39,7 +38,22 @@ copy(std::vector<Ice::Byte>::const_iterator first, std::vector<Ice::Byte>::const { memcpy(&*result, &*first, last - first); } -*/ + +template<> +void +copy(std::string::const_iterator first, std::string::const_iterator last, + std::vector<Ice::Byte>::iterator result) +{ + memcpy(&*result, &*first, last - first); +} + +template<> +void +copy(std::vector<Ice::Byte>::const_iterator first, std::vector<Ice::Byte>::const_iterator last, + std::string::iterator result) +{ + memcpy(&*result, &*first, last - first); +} using namespace std; using namespace Ice; @@ -82,7 +96,13 @@ inlineResize(Buffer* buffer, int total) { throw MemoryLimitException(__FILE__, __LINE__); } - buffer->b.reserve(max(static_cast<size_t>(total), 2 * buffer->b.capacity())); + + int capacity = buffer->b.capacity(); + if(capacity < total) + { + buffer->b.reserve(max(total, 2 * capacity)); + } + buffer->b.resize(total); } @@ -99,6 +119,7 @@ IceInternal::BasicStream::reserve(int total) { throw MemoryLimitException(__FILE__, __LINE__); } + b.reserve(total); } |