GRPC C++
1.26.0
src
core
lib
iomgr
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
19
#include <
grpc/support/port_platform.h
>
20
21
#include <functional>
22
23
#include "
src/core/lib/debug/trace.h
"
24
#include "
src/core/lib/gprpp/atomic.h
"
25
#include "
src/core/lib/gprpp/debug_location.h
"
26
#include "
src/core/lib/gprpp/mpscq.h
"
27
#include "
src/core/lib/gprpp/ref_counted.h
"
28
29
#ifndef GRPC_CORE_LIB_IOMGR_LOGICAL_THREAD_H
30
#define GRPC_CORE_LIB_IOMGR_LOGICAL_THREAD_H
31
32
namespace
grpc_core
{
33
extern
DebugOnlyTraceFlag
grpc_logical_thread_trace
;
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};
48
MultiProducerSingleConsumerQueue
queue_;
49
};
50
}
/* namespace grpc_core */
51
52
#endif
/* GRPC_CORE_LIB_IOMGR_LOGICAL_THREAD_H */
mpscq.h
grpc_core::Atomic< size_t >
grpc_core::DebugLocation
Definition:
debug_location.h:31
grpc_core
Internal thread interface.
Definition:
backoff.h:26
grpc_core::RefCounted
Definition:
ref_counted.h:248
trace.h
grpc_core::LogicalThread
Definition:
logical_thread.h:39
grpc_core::MultiProducerSingleConsumerQueue
Definition:
mpscq.h:34
grpc_core::LogicalThread::Run
void Run(std::function< void()> callback, const grpc_core::DebugLocation &location)
debug_location.h
ref_counted.h
atomic.h
grpc_core::grpc_logical_thread_trace
DebugOnlyTraceFlag grpc_logical_thread_trace
grpc_core::DebugOnlyTraceFlag
TraceFlag DebugOnlyTraceFlag
Definition:
trace.h:115
port_platform.h
Generated on Wed Sep 13 2023 00:00:00 for GRPC C++ by
1.8.20