Add proper documentation of ordering and thread-safety for

streaming (sync and async) APIs
pull/6947/head
vjpai 9 years ago
parent fa9b7c1bc6
commit b9df2760ed
  1. 10
      include/grpc++/impl/codegen/async_stream.h
  2. 14
      include/grpc++/impl/codegen/completion_queue.h
  3. 10
      include/grpc++/impl/codegen/sync_stream.h

@ -52,11 +52,14 @@ class ClientAsyncStreamingInterface {
/// Request notification of the reading of the initial metadata. Completion
/// will be notified by \a tag on the associated completion queue.
/// This call is optional, but if it is used, it cannot be used concurrently
/// with Read
///
/// \param[in] tag Tag identifying this request.
virtual void ReadInitialMetadata(void* tag) = 0;
/// Request notification completion.
/// Indicate that the stream is to be finished and request notification
/// Should not be used concurrently with other operations
///
/// \param[out] status To be updated with the operation status.
/// \param[in] tag Tag identifying this request.
@ -71,6 +74,8 @@ class AsyncReaderInterface {
/// Read a message of type \a R into \a msg. Completion will be notified by \a
/// tag on the associated completion queue.
/// This is thread-safe with respect to other streaming APIs except for Finish
/// on the same stream.
///
/// \param[out] msg Where to eventually store the read message.
/// \param[in] tag The tag identifying the operation.
@ -88,6 +93,7 @@ class AsyncWriterInterface {
/// Only one write may be outstanding at any given time. This means that
/// after calling Write, one must wait to receive \a tag from the completion
/// queue BEFORE calling Write again.
/// This is thread-safe with respect to Read
///
/// \param[in] msg The message to be written.
/// \param[in] tag The tag identifying the operation.
@ -158,6 +164,7 @@ class ClientAsyncWriterInterface : public ClientAsyncStreamingInterface,
public AsyncWriterInterface<W> {
public:
/// Signal the client is done with the writes.
/// Thread-safe with respect to Read
///
/// \param[in] tag The tag identifying the operation.
virtual void WritesDone(void* tag) = 0;
@ -229,6 +236,7 @@ class ClientAsyncReaderWriterInterface : public ClientAsyncStreamingInterface,
public AsyncReaderInterface<R> {
public:
/// Signal the client is done with the writes.
/// Thread-safe with respect to Read
///
/// \param[in] tag The tag identifying the operation.
virtual void WritesDone(void* tag) = 0;

@ -31,8 +31,18 @@
*
*/
/// A completion queue implements a concurrent producer-consumer queue, with two
/// main methods, \a Next and \a AsyncNext.
/// A completion queue implements a concurrent producer-consumer queue, with
/// two main API-exposed methods: \a Next and \a AsyncNext. These
/// methods are the essential component of the gRPC C++ asynchronous API.
/// There is also a Shutdown method to indicate that a given completion queue
/// will no longer have regular events. This must be called before the
/// completion queue is destroyed.
/// All completion queue APIs are thread-safe and may be used concurrently with
/// any other completion queue API invocation; it is acceptable to have
/// multiple threads calling Next or AsyncNext on the same or different
/// completion queues, or to call these methods concurrently with a Shutdown
/// elsewhere. All of these should be completed, though, before a completion
/// queue destructor is called.
#ifndef GRPCXX_IMPL_CODEGEN_COMPLETION_QUEUE_H
#define GRPCXX_IMPL_CODEGEN_COMPLETION_QUEUE_H

@ -71,6 +71,8 @@ class ReaderInterface {
virtual ~ReaderInterface() {}
/// Blocking read a message and parse to \a msg. Returns \a true on success.
/// This is thread-safe with respect to other streaming APIs except for Finish
/// on the same stream. (Finish must be called as described above.)
///
/// \param[out] msg The read message.
///
@ -87,6 +89,7 @@ class WriterInterface {
virtual ~WriterInterface() {}
/// Blocking write \a msg to the stream with options.
/// This is thread-safe with respect to Read
///
/// \param msg The message to be written to the stream.
/// \param options Options affecting the write operation.
@ -95,6 +98,7 @@ class WriterInterface {
virtual bool Write(const W& msg, const WriteOptions& options) = 0;
/// Blocking write \a msg to the stream with default options.
/// This is thread-safe with respect to Read
///
/// \param msg The message to be written to the stream.
///
@ -174,7 +178,8 @@ class ClientWriterInterface : public ClientStreamingInterface,
public WriterInterface<W> {
public:
/// Half close writing from the client.
/// Block until writes are completed.
/// Block until currently-pending writes are completed.
/// Thread safe with respect to Read operations only
///
/// \return Whether the writes were successful.
virtual bool WritesDone() = 0;
@ -257,7 +262,8 @@ class ClientReaderWriterInterface : public ClientStreamingInterface,
/// the metadata will be available in ClientContext after the first read.
virtual void WaitForInitialMetadata() = 0;
/// Block until writes are completed.
/// Block until currently-pending writes are completed.
/// Thread-safe with respect to Read
///
/// \return Whether the writes were successful.
virtual bool WritesDone() = 0;

Loading…
Cancel
Save