// // // Copyright 2018 gRPC authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // // #ifndef GRPCPP_SUPPORT_CALLBACK_COMMON_H #define GRPCPP_SUPPORT_CALLBACK_COMMON_H #include <functional> #include <grpc/grpc.h> #include <grpc/impl/grpc_types.h> #include <grpc/support/log.h> #include <grpcpp/impl/call.h> #include <grpcpp/impl/codegen/channel_interface.h> #include <grpcpp/impl/completion_queue_tag.h> #include <grpcpp/support/config.h> #include <grpcpp/support/status.h> namespace grpc { namespace internal { /// An exception-safe way of invoking a user-specified callback function // TODO(vjpai): decide whether it is better for this to take a const lvalue // parameter or an rvalue parameter, or if it even matters template <class Func, class... Args> void CatchingCallback(Func&& func, Args&&... args) { … } template <class Reactor, class Func, class... Args> Reactor* CatchingReactorGetter(Func&& func, Args&&... args) { … } // The contract on these tags is that they are single-shot. They must be // constructed and then fired at exactly one point. There is no expectation // that they can be reused without reconstruction. class CallbackWithStatusTag : public grpc_completion_queue_functor { … }; /// CallbackWithSuccessTag can be reused multiple times, and will be used in /// this fashion for streaming operations. As a result, it shouldn't clear /// anything up until its destructor class CallbackWithSuccessTag : public grpc_completion_queue_functor { … }; } // namespace internal } // namespace grpc #endif // GRPCPP_SUPPORT_CALLBACK_COMMON_H