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 
25 
26 #include <grpc/support/atm.h>
27 
29 
30 namespace grpc_core {
31 
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 {
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.
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:
66 
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