GRPC Core  9.0.0
logical_thread.h
Go to the documentation of this file.
1 /*
2  *
3  * Copyright 2019 gRPC authors.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  */
18 
20 
21 #include <functional>
22 
28 
29 #ifndef GRPC_CORE_LIB_IOMGR_LOGICAL_THREAD_H
30 #define GRPC_CORE_LIB_IOMGR_LOGICAL_THREAD_H
31 
32 namespace grpc_core {
34 
35 // LogicalThread is a mechanism to schedule callbacks in a synchronized manner.
36 // All callbacks scheduled on a LogicalThread instance will be executed serially
37 // in a borrowed thread. The API provides a FIFO guarantee to the execution of
38 // callbacks scheduled on the thread.
39 class LogicalThread : public RefCounted<LogicalThread> {
40  public:
41  void Run(std::function<void()> callback,
42  const grpc_core::DebugLocation& location);
43 
44  private:
45  void DrainQueue();
46 
47  Atomic<size_t> size_{0};
49 };
50 } /* namespace grpc_core */
51 
52 #endif /* GRPC_CORE_LIB_IOMGR_LOGICAL_THREAD_H */
Definition: logical_thread.h:39
Definition: debug_location.h:31
DebugOnlyTraceFlag grpc_logical_thread_trace(false, "logical_thread")
Definition: logical_thread.h:33
Round Robin Policy.
Definition: backend_metric.cc:24
Definition: trace.h:61
Definition: ref_counted.h:248
void Run(std::function< void()> callback, const grpc_core::DebugLocation &location)
Definition: logical_thread.cc:36