Main Page
Related Pages
Modules
Namespaces
Namespace List
Namespace Members
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Functions
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Variables
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Typedefs
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
r
s
t
u
v
w
y
z
Enumerations
a
b
c
d
e
f
g
h
i
j
l
m
n
o
p
r
s
t
u
v
w
Enumerator
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
r
s
t
u
z
Classes
Class List
Class Hierarchy
Class Members
All
:
[
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
Functions
[
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
Variables
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Typedefs
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
r
s
t
u
v
w
y
Enumerations
a
b
c
d
e
f
h
i
k
l
m
n
o
p
r
s
t
u
v
w
Enumerator
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
z
Properties
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
r
s
t
u
v
w
Related Functions
:
a
b
c
d
e
f
g
h
i
j
l
m
n
o
p
q
r
s
t
u
v
w
z
Files
File List
File Members
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Functions
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
z
Variables
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Typedefs
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
x
z
Enumerations
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
r
s
t
u
v
w
x
Enumerator
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
r
s
t
u
v
w
x
Macros
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
grpc
src
core
lib
iomgr
lockfree_event.h
Go to the documentation of this file.
1
/*
2
*
3
* Copyright 2017 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
#ifndef GRPC_CORE_LIB_IOMGR_LOCKFREE_EVENT_H
20
#define GRPC_CORE_LIB_IOMGR_LOCKFREE_EVENT_H
21
22
/* Lock free event notification for file descriptors */
23
24
#include <
grpc/support/port_platform.h
>
25
26
#include <
grpc/support/atm.h
>
27
28
#include "
src/core/lib/iomgr/closure.h
"
29
30
namespace
grpc_core
{
31
32
class
LockfreeEvent
{
33
public
:
34
LockfreeEvent
();
35
36
LockfreeEvent
(
const
LockfreeEvent
&) =
delete
;
37
LockfreeEvent
&
operator=
(
const
LockfreeEvent
&) =
delete
;
38
39
// These methods are used to initialize and destroy the internal state. These
40
// cannot be done in constructor and destructor because SetReady may be called
41
// when the event is destroyed and put in a freelist.
42
void
InitEvent
();
43
void
DestroyEvent
();
44
45
// Returns true if fd has been shutdown, false otherwise.
46
bool
IsShutdown
()
const
{
47
return
(
gpr_atm_no_barrier_load
(&
state_
) &
kShutdownBit
) != 0;
48
}
49
50
// Schedules \a closure when the event is received (see SetReady()) or the
51
// shutdown state has been set. Note that the event may have already been
52
// received, in which case the closure would be scheduled immediately.
53
// If the shutdown state has already been set, then \a closure is scheduled
54
// with the shutdown error.
55
void
NotifyOn
(
grpc_closure
*
closure
);
56
57
// Sets the shutdown state. If a closure had been provided by NotifyOn and has
58
// not yet been scheduled, it will be scheduled with \a shutdown_error.
59
bool
SetShutdown
(
grpc_error_handle
shutdown_error);
60
61
// Signals that the event has been received.
62
void
SetReady
();
63
64
private
:
65
enum
State
{
kClosureNotReady
= 0,
kClosureReady
= 2,
kShutdownBit
= 1 };
66
67
gpr_atm
state_
;
68
};
69
70
}
// namespace grpc_core
71
72
#endif
/* GRPC_CORE_LIB_IOMGR_LOCKFREE_EVENT_H */
grpc_core::LockfreeEvent::DestroyEvent
void DestroyEvent()
Definition:
lockfree_event.cc:75
grpc_core::LockfreeEvent
Definition:
lockfree_event.h:32
gpr_atm_no_barrier_load
#define gpr_atm_no_barrier_load(p)
Definition:
impl/codegen/atm_gcc_atomic.h:53
grpc_core
Definition:
call_metric_recorder.h:31
grpc_core::LockfreeEvent::kShutdownBit
@ kShutdownBit
Definition:
lockfree_event.h:65
closure.h
grpc_core::LockfreeEvent::State
State
Definition:
lockfree_event.h:65
grpc_core::LockfreeEvent::LockfreeEvent
LockfreeEvent()
Definition:
lockfree_event.cc:63
grpc_core::LockfreeEvent::operator=
LockfreeEvent & operator=(const LockfreeEvent &)=delete
grpc_core::LockfreeEvent::SetShutdown
bool SetShutdown(grpc_error_handle shutdown_error)
Definition:
lockfree_event.cc:171
gpr_atm
intptr_t gpr_atm
Definition:
impl/codegen/atm_gcc_atomic.h:32
grpc_core::LockfreeEvent::NotifyOn
void NotifyOn(grpc_closure *closure)
Definition:
lockfree_event.cc:95
grpc_core::LockfreeEvent::kClosureReady
@ kClosureReady
Definition:
lockfree_event.h:65
grpc_core::LockfreeEvent::InitEvent
void InitEvent()
Definition:
lockfree_event.cc:65
grpc_core::LockfreeEvent::SetReady
void SetReady()
Definition:
lockfree_event.cc:231
closure
Definition:
proxy.cc:59
grpc_core::LockfreeEvent::IsShutdown
bool IsShutdown() const
Definition:
lockfree_event.h:46
atm.h
grpc_error
Definition:
error_internal.h:42
grpc_core::LockfreeEvent::state_
gpr_atm state_
Definition:
lockfree_event.h:67
grpc_closure
Definition:
closure.h:56
grpc_core::LockfreeEvent::kClosureNotReady
@ kClosureNotReady
Definition:
lockfree_event.h:65
port_platform.h
grpc
Author(s):
autogenerated on Thu Mar 13 2025 03:00:29