Commit Graph

2196 Commits

Author SHA1 Message Date
Roger Meier
085a3e7b60 THRIFT-926 Miscellaneous C++ improvements
changing single destructor call time limit from 500us to 1000us
build does not fail on busy machines



git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@1006030 13f79535-47bb-0310-9956-ffa450edef68
2010-10-08 21:23:35 +00:00
Roger Meier
50e4349463 THRIFT-581 Add a testsuite for txThrift (Twisted) / py.twisted
Patch: Esteve Fernandez



git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@1005923 13f79535-47bb-0310-9956-ffa450edef68
2010-10-08 17:46:06 +00:00
Bryan Duxbury
f969bcb7d8 THRIFT-862. java: Async client issues / improvements
This patch improves quite a large number of things about the async client code.

Patch: Ning Liang

git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@1005221 13f79535-47bb-0310-9956-ffa450edef68
2010-10-06 20:04:40 +00:00
Bryan Duxbury
b3d0aa0c82 THRIFT-946. java: Augment FieldValueMetaData so it differentiates 'string' and 'binary' fields.
This patch adds a new method to the FieldMetaData class that indicates binary or not.

Patch: Mathias Herberts

git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@1005220 13f79535-47bb-0310-9956-ffa450edef68
2010-10-06 20:00:03 +00:00
David Reiss
ef6a1766ce THRIFT-927. php: Option to support modifying the PHP include path
Make the PHP generator recognize a new-style namespace called "php.path".
If it is present, it is segmented and used as a path to include the
generated code.  (It goes between "packages" and the Thrit file basename.)

git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@1005172 13f79535-47bb-0310-9956-ffa450edef68
2010-10-06 17:10:55 +00:00
David Reiss
25df8e7e4a THRIFT-926. cpp: Better exception handling in TSimpleServer
Move processing code out of main try block and created individual
try/catch's for closing down the client and it's transports (to avoid
issues with throwing exceptions from a catch block).

Also converted to using GlobalOutput instead of cerr.

git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@1005171 13f79535-47bb-0310-9956-ffa450edef68
2010-10-06 17:10:54 +00:00
David Reiss
46e4f252dc THRIFT-926. cpp: remove auto-stringification in TLogging.h
The T_DEBUG* and T_ERROR* macros used preprocessor stringification to
stringify the format string argument.  This was weird and unintuitive.

With the old behavior:

- Quotes surrounding the format string were included in the message:
  T_DEBUG("this is a test") --> expanded to  "\"this is a test\""

- Backslashes in the string are escaped so they print literally:
  T_DEBUG("foo\nbar")       --> expanded to  "\"foo\\nbar\""

- Standard fixed-width integer format macros don't work:
  T_DEBUG("x: %" PRIi64, x) --> expanded to  "\"x: %\" PRIi64"

The last item is particularly problematic, since it prevents 64-bit
values from being logged portably.

With the new code, the following will no longer compile:

  T_DEBUG(this is my log message: %d, 5)

I don't think that is a bad thing, though.

git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@1005170 13f79535-47bb-0310-9956-ffa450edef68
2010-10-06 17:10:53 +00:00
David Reiss
89a12942d2 THRIFT-926. cpp: Better buffer management for TNonblockingServer
Add two improvements to memory management in TNonblocking server:
- Separate the receive code into two distinct states: one for receiving
  the frame header and one for the frame content.  This allows us to
  size the initial read buffer based on the initial frame size, rather
  than allocating an arbitrary amount of memory before reading the
  header.
- Allow setting the initial write buffer size based on the application's
  expected response size.

git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@1005169 13f79535-47bb-0310-9956-ffa450edef68
2010-10-06 17:10:52 +00:00
David Reiss
7e729d2074 THRIFT-926. cpp: Let TMemoryBuffer::resetBuffer() set size of self-allocated buffer
Although there is a constructor that allows a TMemoryBuffer to be
created with an internally-allocated buffer of a desired size, there was
no way for resetBuffer to obtain analogous behavior. This change causes
the appropriate constructor to be used.

git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@1005168 13f79535-47bb-0310-9956-ffa450edef68
2010-10-06 17:10:51 +00:00
David Reiss
f673509f1b THRIFT-926. cpp: Thrift: throw bad_alloc when malloc fails, not something else
When malloc/realloc fail, we've typically just thrown a TException. This
allows a server that should simply crash when out of memory to survive
in a strage state, with various bad consequences. Instead, we should
throw bad_alloc and just not catch it (or if we decide to, be very
careful to respond properly).

git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@1005167 13f79535-47bb-0310-9956-ffa450edef68
2010-10-06 17:10:49 +00:00
David Reiss
2991a0f376 THRIFT-926. cpp: TFramedTransport: Uphold the strong exception safety guarantee
Previously, if we had a new[] failure when growing a TFramedTransport
write buffer, we would leave the buffer in an invalid state (wBufSize_
would reflect the desired size, rather than the actual size).  Now, we
make no change to any member variables if new[] fails.

git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@1005166 13f79535-47bb-0310-9956-ffa450edef68
2010-10-06 17:10:47 +00:00
David Reiss
ece1a089ec THRIFT-926. cpp: TMemoryBuffer: Uphold the strong exception safety guarantee
Previously, if we had a realloc failure when growing a TMemoryBuffer, we
would leave the buffer in an invalid state (bufferSize_ would reflect
the desired size, rather than the actual size).  Now, we make no change
to any member variables if realloc fails.

git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@1005165 13f79535-47bb-0310-9956-ffa450edef68
2010-10-06 17:10:46 +00:00
David Reiss
54bec5dbd8 THRIFT-926. cpp: Add configurable buffer recycling for TNonblockingServer
Add methods to TNonblockingServer to set the maximum size of idle read
and write buffers and the check interval (in calls).  When checked, if
the buffers are larger than the configured maximum, they will be resized
down the to maximum size.

git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@1005164 13f79535-47bb-0310-9956-ffa450edef68
2010-10-06 17:10:45 +00:00
David Reiss
7197efb849 THRIFT-926. cpp: Revert r750153 to make way for more flexible version
r750153 caused TNonblockingServer to reset its buffers every 512 calls.
A more configurable version was developed internally, so I'm reverting
this rev first to avoid conflicts.

git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@1005163 13f79535-47bb-0310-9956-ffa450edef68
2010-10-06 17:10:43 +00:00
David Reiss
109693c82a THRIFT-929. cpp: Convert tests to use boost 1.37
The boost test framework has changed significantly from boost 1.34 to
1.37.  Quite a few new features have been added, and some annoying bugs
have been fixed.

This change now builds the thrift tests against boost 1.37, and updates
them to use some of the newer features.

git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@1005162 13f79535-47bb-0310-9956-ffa450edef68
2010-10-06 17:10:42 +00:00
David Reiss
0a2d81e816 THRIFT-926. cpp: Fix inconsistencies in transport read() behavior
- TBufferedTransport::borrow() could block if not enough data was
  available.  Now it returns NULL immediately in this case, like all
  other transports.

- TBufferedTransport::read() could block some data was available in the
  readahead buffer, but not enough to satisfy the request.  It would
  attempt to call read() on the underlying transport, but this might
  block.  Now it just returns the remaining data in the readahead
  buffer.  The caller is responsible for calling read() again to get the
  rest of the data they want.

- TFrameTransport::read() threw an exception if read() on the underlying
  transport returned 0 when looking for a frame header.  Now
  TFrameTransport::read() returns 0, too.  (It still throws an exception
  if the underlying transport returns 0 after a partial frame or frame
  header has been read.)

- TFDTransport::read() threw an exception on EINTR.  Now it retries up
  to 5 times, similarly to the way TSocket::read() behaves.

- TZlibTransport::read() could block when less data than was requested
  is available.  Now it only calls read() on the underlying transport
  when it would otherwise have nothing to return.

  This does mean that TZlibTransport::read() now often returns less data
  than is actually available at the time.  This required updating
  several of the ZlibTest tests to use readAll() instead of read(),
  since they previously assumed read() would return all available data.

git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@1005161 13f79535-47bb-0310-9956-ffa450edef68
2010-10-06 17:10:40 +00:00
David Reiss
e5c435cccf THRIFT-929. cpp: Add tests to verify blocking read behavior
Add tests that check to see whether or not read() and borrow() block
when called with a length larger than the amount of data currently
available.

At the moment, not all of the transports behave the same way.  I believe
the desired behavior is:

  When M bytes are available, and 0 < M < N:
  - read(N): return M bytes immediately
  - borrow(N): return NULL immediately

  When 0 bytes are available:
  - read(N): In this case, it is acceptable either to immediately return
    0, or to block until some data is available.  If the transport
    blocks, it returns immediately when some date becomes available,
    even if less than N bytes are available.
  - borrow(N): return NULL immediately

- The borrow() tests fail when using TBufferedTransport.
  TBufferedTransport incorrectly blocks until the amount of data
  requested is available.

- test_read_none_available() fails when using TFramedTransport.
  Calling read() on a TFramedTransport when no data is available throws
  an exception instead of returning 0.

- test_read_none_available() fails when using TFDTransport.  This is
  partly just an artifact of the fact that I use SIGALRM as part of this
  test.  Unlike TSocket, TFDTransport doesn't retry after EINTR.

- test_read_part_available() fails when using TZlibTransport around a
  transport that has blocking read() behavior.  TZlibTransport::read()
  loops calling read() on the underlying transport.  It should probably
  break out of the loop and return to the caller as soon as it has
  uncompressed any data, even if it is less than requested and more
  might be available.  Once some data has been uncompressed,
  TZlibTransport cannot risk calling read() again since it might block.

Will commit fixes for these separately.

git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@1005160 13f79535-47bb-0310-9956-ffa450edef68
2010-10-06 17:10:38 +00:00
David Reiss
d4788dfd4a THRIFT-929. cpp: Test wrapper transports more thoroughly
UpdateS TransportTest so that the wrapper transports
(TBufferedTransport, TFramedTransport, TZlibTransport) are tested with a
wider variety of inner transports.  Previously they were only tested
using TMemoryBuffer.  Now all other transports are also tested wrapped
inside each of these transports.

git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@1005159 13f79535-47bb-0310-9956-ffa450edef68
2010-10-06 17:10:37 +00:00
David Reiss
0c025e8f52 THRIFT-929. cpp: Update TransportTest to test TSocket
Made the TSocket(int fd) constructor public, so TransportTest can create
a connected pair of TSocket transports using socketpair().

git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@1005158 13f79535-47bb-0310-9956-ffa450edef68
2010-10-06 17:10:36 +00:00
David Reiss
65e62d3741 THRIFT-929. cpp: Reduce default buffer sizes for TransportTest
Reduce the default test buffer sizes by about 30x, reducing the time it
takes to run TransportTest from about 1 minute to about 2 seconds.  I
added a --size-multiplier argument that can be used to adjust the sizes
of all test buffers, so developers can still run with large buffer sizes
when desired.

git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@1005157 13f79535-47bb-0310-9956-ffa450edef68
2010-10-06 17:10:35 +00:00
David Reiss
4f9efdb460 THRIFT-926. cpp: Fix bugs in TFileTransport::flush()
Previously flush() had race conditions that could cause it to return
before all data had actually been flushed to disk.  Now the writer
makes sure both buffer queues have been flushed when forceFlush_ is set.

Also, flush() did not wake up the writer thread, so it normally had to
wait for the writer thread to wake up on its own time.  (By default,
this could take up to 3 seconds.)

git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@1005156 13f79535-47bb-0310-9956-ffa450edef68
2010-10-06 17:10:33 +00:00
David Reiss
4199377a7c THRIFT-926. cpp: TFileTransportTest timing slightly more lenient
Several of the TFileTransportTest tests check wall clock time to make
sure the writer thread processes operations quickly enough, and isn't
hanging.  However, this can easily result in false failures if we don't
get enough processor time.  This commit makes a few changes to reduce
the number of these failures.

- No longer fail if a single destructor call takes more than 500us.
  We only require 90% of the calls to complete in 500us.  No call may
  take more than 100ms, though.  With this change, the test passes most
  of the time now, even while an "fbmake opt" task is running in
  parallel.

- In the flush_max_us tests, make sure the writer thread is started
  before we start recording timing.  Otherwise, creating the thread
  could take long enough to throw off the numbers for the first fsync()
  call.

Also tested with the pthread_cond_signal() in the TFileTransport
destructor commented out, to make sure the test still fails properly
when the destructor takes too long.

git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@1005155 13f79535-47bb-0310-9956-ffa450edef68
2010-10-06 17:10:31 +00:00
David Reiss
709b69f14c THRIFT-926. cpp: Fix destructor behavior of TFileTransport
Set closing_ to true before we wake up the writer thread in the
destructor.  This way the writer thread flushes the data and exits when
it is woken up.

Previously the writer thread could end up going through 2 full timeout
cycles before exiting.  The writer thread could wake up, notice it has
nothing to do since closing_ is not set, and immediately go back to
sleep.  The destructor would then proceed to call flush(), which would
wait for the writer thread to wake up (1 full time out) and clear the
forceFlush_ flag.  After flush returns, the destructor would set
closing_.  It could take the writer thread another full timeout to wake
up again and process this flag.

There were also some points where the worker threads would detect the
closing_ state in their loops and automatically close the file, but did
not zero out the file descriptor, then the destructer attempted to close
the same file.  Fix by simply zeroing out the fd_ at these points.

git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@1005154 13f79535-47bb-0310-9956-ffa450edef68
2010-10-06 17:10:30 +00:00
David Reiss
0e0eb35452 THRIFT-926. cpp: Don't sleep in TFileTransport if we have data to write
Previously, the TFileTransport writer thread behaved as follows:

  while true:
    wait for main thread to notify new data in enqueueBuffer_
    swap(enqueueBuffer_, dequeueBuffer_)
    write out everything in dequeueBuffer_

Now the behavior is:

  while true:
    if enqueueBuffer_ is empty
      wait for main thread to notify new data in enqueueBuffer_
    swap(enqueueBuffer_, dequeueBuffer_)
    write out everything in dequeueBuffer_

The old behavior had a couple problems:
- Writes that arrived while the writer thread was writing
  dequeueBuffer_ wouldn't get processed immediately.  The writer thread
  would always wait until another write occurred after it started its
  condition variable wait, or until it timed out (3 seconds by default).

- If the main thread was writing fast enough to fill up enqueueBuffer_
  while the writer thread was still writing out dequeueBuffer_, it would
  block the next write call until the writer thread swapped the buffers.
  Unfortunately, the writer thread waits to do this until it the main
  thread notifies it of another write.  This deadlock is only broken by
  the 3 second timeout.  Performance then tanks, since the writer thread
  now always sleeps 3 seconds each time around the loop.

git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@1005153 13f79535-47bb-0310-9956-ffa450edef68
2010-10-06 17:10:29 +00:00
David Reiss
a0e1159716 THRIFT-926. cpp: remove "standalone" distinction in TZlibTransport
Now that TZlibTransport::flush() behaves the same way as other
transports, there is no need to distinguish between RPC and standalone
behavior for TZlibTransport.

git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@1005152 13f79535-47bb-0310-9956-ffa450edef68
2010-10-06 17:10:27 +00:00
David Reiss
e94fa3391d THRIFT-926. cpp: Make TZlibTransport::flush() behave like other transports
Previously, TZlibTransport::flush() finished the zlib stream, so calling
write() after flush() would result in an error.  Now it just flushes the
data, without finishing the stream.  A new TZlibTransport::finish()
function has been added to finish the stream.

This breaks compatibility.  I'm aware of anyone using this code outside
of Facebook, though.

git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@1005151 13f79535-47bb-0310-9956-ffa450edef68
2010-10-06 17:10:26 +00:00
David Reiss
f2abcf9a56 THRIFT-929. cpp: Use boost::lognormal_distribution in ZlibTest
This way we no longer have to have a huge hard-coded list of numbers in
the source code.  The distribution is randomly generated for each run.
(Although the --seed argument can be used for repeatablity.)

git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@1005150 13f79535-47bb-0310-9956-ffa450edef68
2010-10-06 17:10:24 +00:00
David Reiss
9a961e7750 THRIFT-929. cpp: Convert ZlibTest to use the boost unit test framework
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@1005149 13f79535-47bb-0310-9956-ffa450edef68
2010-10-06 17:10:23 +00:00
David Reiss
3cc9dab229 THRIFT-929. cpp: Remove TZlibTest dependency on filesystem data
Previously, ZlibTest read a file from disk to get data to test with.
It would fail unless gen-cpp/DebugProtoTest_types.tcc was present in the
current directory and was at least 32kB long.

Now ZlibTest simply generates 3 separate buffers to test with.  The
first buffer is just all "a"s, the second is some random sequential
runs, and the third is completely random.  They usually seem to have
compression ratios of around 315:1, 4:1, and 1:1, respectively.

git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@1005148 13f79535-47bb-0310-9956-ffa450edef68
2010-10-06 17:10:21 +00:00
David Reiss
56cb796bce THRIFT-929. cpp: Fix a couple minor issues in ZlibTest
- Add a necessary cast.
- Check buffer sizes more carefully to allow for different read/write
  size distributions.

git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@1005147 13f79535-47bb-0310-9956-ffa450edef68
2010-10-06 17:10:20 +00:00
David Reiss
35dc7695a9 THRIFT-929. cpp: Add unit test for transport functionality
Tests various transport types by writing data, and verifying it can be
read back successfully.  Tests both virtual calls (accessed as
TTransport*) and non-virtual calls (accessed as the appropriate pointer
type, or as TBufferBase* when appropriate).

This is similar to some of the tests already performed in
TMemoryBufferTest and ZlibTest.cpp.  However, this tests a few more
transport types, and it interleaves read and write calls more heavily.
(It currently exposes some bugs in flush() in a couple transports.) It
also exercises both the virtual and non-virtual code paths, now that
read() and write() only result in virtual calls when invoked on a
TTransport*.

TFileTransport currently has several race condition bugs, so most of the
TFileTransport tests ususally fail.  It also has some performance bugs,
causing the TFileTransport tests to take a long time.  Will fix those
issues separately.

git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@1005146 13f79535-47bb-0310-9956-ffa450edef68
2010-10-06 17:10:19 +00:00
David Reiss
105961de04 THRIFT-928. cpp: TNonblockingServer: use TSocket and support TClientInfo
Modify TNonblockingServer to use TSocket for I/O and support server
event handlers; this enables TClientInfo to function with a minor change
to the processing loop.

git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@1005145 13f79535-47bb-0310-9956-ffa450edef68
2010-10-06 17:10:17 +00:00
David Reiss
67f56ec6ab THRIFT-926. cpp: Remove TServerSocket as a friend class of TSocket
This is no longer necessary now that TSocket::TSocket(int) is public.

git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@1005144 13f79535-47bb-0310-9956-ffa450edef68
2010-10-06 17:10:16 +00:00
David Reiss
44ff76f514 THRIFT-925. cpp: Add _VALUES_TO_NAMES enum map
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@1005143 13f79535-47bb-0310-9956-ffa450edef68
2010-10-06 17:10:15 +00:00
David Reiss
64637511d2 THRIFT-924. php: Fix missing comma in generated PHP struct constants
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@1005142 13f79535-47bb-0310-9956-ffa450edef68
2010-10-06 17:10:13 +00:00
David Reiss
a8af11dde6 THRIFT-926. cpp: Fix an errant argument to a debug statement
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@1005141 13f79535-47bb-0310-9956-ffa450edef68
2010-10-06 17:10:11 +00:00
David Reiss
c3b3622158 THRIFT-922. cpp: Add profiling code to help conversion to C++ templates
Add some profiling code to track when potentially unnecessary virtual
calls are made in the thrift C++ serialization and deserialization code.
This can be used to help service implementors determine which places in
their code should be updated to use an appropriate thrift template
class.

git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@1005140 13f79535-47bb-0310-9956-ffa450edef68
2010-10-06 17:10:10 +00:00
David Reiss
2324871334 THRIFT-928. cpp: Thrift Server Client Stats
Add the ability for Thrift servers to monitor client connections.  It is
activated by #including server/TClientInfo.h and creating 1) a
TClientInfoCallHandler passed to the processor with setEventHandler()
and 2) a TClientInforServerHandler passed to the server with
setServerEventHandler().

The result vector, showing active connections, provides client address
and the thrift call it is executing (or last executed), the time
connected, and the number of calls made since connection.

git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@1005139 13f79535-47bb-0310-9956-ffa450edef68
2010-10-06 17:10:08 +00:00
David Reiss
b7762a032a THRIFT-922. cpp: Update C++ generator to emit templatized code
When the "templates" option is passed to the C++ generator, it now emits
templatized versions of the client and processor.  Generated types emit
templatized read() and write() functions.

This allows the generated code to invoke the correct non-virtual
TTransport and TProtocol implementations, resulting in faster
serialization and deserialization.

git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@1005138 13f79535-47bb-0310-9956-ffa450edef68
2010-10-06 17:10:00 +00:00
David Reiss
8dfc732af6 THRIFT-922. cpp: Fix C++ compilation when using list<bool>
The STL specializes vector<bool> to store the values as individual bits, rather
than bools.  Therefore, when using a Thrift list<bool>, readBool() gets invoked
not with a bool&, but with a std::vector<bool>::reference.

TProtocol does provide a readBool(std::vector<bool>::reference) implementation.
However, almost all TProtocol subclasses defined only readBool(bool&), which
hides the other overloaded versions of readBool().  As a result, the code
worked only when accessing TProtocol objects via a "TProtocol*", and not
directly via the subclass type.  When using C++ templates, protocol objects do
get invoked via pointers to the subclass type, causing compile failures when
std::vector<bool> is used.

This change updates the various TProtocol implementations to also provide
readBool(std::vector<bool>::reference).

git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@1005137 13f79535-47bb-0310-9956-ffa450edef68
2010-10-06 17:09:58 +00:00
David Reiss
e71115be6c THRIFT-922. cpp: Templatize binary and compact protocol
Convert TBinaryProtocol and TCompactProtocol to template classes, taking
the transport class as a template parameter.  This allows them to make
non-virtual calls when using the template, improving serialization
performance.

git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@1005136 13f79535-47bb-0310-9956-ffa450edef68
2010-10-06 17:09:56 +00:00
David Reiss
6806fb836a THRIFT-922. cpp: Convert protocol classes to use non-virtual functions
Updated the thrift protocol classes to use non-virtual calls for most
functions.  The correct implementation is determined at compile time via
templates now.  Only the base TProtocol class falls back to using
virtual function calls.

git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@1005135 13f79535-47bb-0310-9956-ffa450edef68
2010-10-06 17:09:52 +00:00
David Reiss
e879c2f4db THRIFT-922. cpp: Convert transport classes to use non-virtual calls
Update the thrift transport classes to use non-virtual calls for most
functions.  The correct implementation is determined at compile time via
templates now.  Only the base TTransport class falls back to using
virtual function calls.

git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@1005134 13f79535-47bb-0310-9956-ffa450edef68
2010-10-06 17:09:50 +00:00
David Reiss
72fd0b415f THRIFT-922. cpp: Add shortcutted version of readAll() in TBufferBase
Just perform a memcpy() if all of the requested data is available in the
buffer.  This improves performance a little in the common case.  It has
a bigger impact with the upcoming template changes.

git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@1005133 13f79535-47bb-0310-9956-ffa450edef68
2010-10-06 17:09:47 +00:00
David Reiss
ea051ca793 THRIFT-922. cpp: When reading strings, borrow first
Attempt to get a pointer to the internal transport buffer before copying
onto the heap.  This improves performance TFramedTransport and
TMemoryBuffer, and with TBufferedTransport if the string fits within the
buffer.

git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@1005132 13f79535-47bb-0310-9956-ffa450edef68
2010-10-06 17:09:46 +00:00
David Reiss
c6b4cab89c THRIFT-923. cpp: Add completion notification to async clients
Add a virtual function "completed__(bool)" to xxxCobClient that is
called by recv_xxx() after reception of a response (arg = true) or an
exception (arg = false). This allows the TAsyncClient to intercede at
that point, permitting, e.g., the load-balancing of persistent
connections that would otherwise remain bound to a single server.

A new "no_client_completion" flag inhibits generation of this mechanism.

git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@1005131 13f79535-47bb-0310-9956-ffa450edef68
2010-10-06 17:09:45 +00:00
David Reiss
f62126dbb3 THRIFT-928. cpp: Prefix function name with service name
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@1005130 13f79535-47bb-0310-9956-ffa450edef68
2010-10-06 17:09:43 +00:00
David Reiss
ef7200f6e8 THRIFT-928. cpp: Include request/response size in processor callbacks
Required updating transport interface.

git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@1005129 13f79535-47bb-0310-9956-ffa450edef68
2010-10-06 17:09:42 +00:00
David Reiss
18cd0f0334 THRIFT-928. cpp: Make clients call writeEnd on their transports before flush
Changing the order of these calls makes more sense from the perspective
of logical operations.  It also simplifies the upcoming stats collection
code.  No clients should be affected.

git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@1005128 13f79535-47bb-0310-9956-ffa450edef68
2010-10-06 17:09:39 +00:00
David Reiss
5ddabb8e3f THRIFT-923. cpp: Implement a fully nonblocking server and client
There are three major parts of this:
1/ New callback-style interfaces for for a few key Thrift components:
   TAsyncProcessor for servers and TAsyncChannel for clients.
2/ Concrete implementations of TAsyncChannel and a server for
   TAsyncProcessor based on evhttp.
3/ Async-style code generation for C++

git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@1005127 13f79535-47bb-0310-9956-ffa450edef68
2010-10-06 17:09:37 +00:00