// // // Copyright 2016 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 GRPC_SRC_CORE_LIB_IOMGR_COMBINER_H #define GRPC_SRC_CORE_LIB_IOMGR_COMBINER_H #include <grpc/support/port_platform.h> #include <stddef.h> #include <grpc/support/atm.h> #include "src/core/lib/debug/trace.h" #include "src/core/lib/iomgr/exec_ctx.h" namespace grpc_core { // TODO(yashkt) : Remove this class and replace it with a class that does not // use ExecCtx class Combiner { … }; } // namespace grpc_core // Provides serialized access to some resource. // Each action queued on a combiner is executed serially in a borrowed thread. // The actual thread executing actions may change over time (but there will only // ever be one at a time). // Initialize the lock, with an optional workqueue to shift load to when // necessary grpc_core::Combiner* grpc_combiner_create(void); #ifndef NDEBUG #define GRPC_COMBINER_DEBUG_ARGS … #define GRPC_COMBINER_REF(combiner, reason) … #define GRPC_COMBINER_UNREF(combiner, reason) … #else #define GRPC_COMBINER_DEBUG_ARGS #define GRPC_COMBINER_REF … #define GRPC_COMBINER_UNREF … #endif // Ref/unref the lock, for when we're sharing the lock ownership // Prefer to use the macros above grpc_core::Combiner* grpc_combiner_ref( grpc_core::Combiner* lock GRPC_COMBINER_DEBUG_ARGS); void grpc_combiner_unref(grpc_core::Combiner* lock GRPC_COMBINER_DEBUG_ARGS); bool grpc_combiner_continue_exec_ctx(); extern grpc_core::DebugOnlyTraceFlag grpc_combiner_trace; #endif // GRPC_SRC_CORE_LIB_IOMGR_COMBINER_H