chromium/third_party/grpc/src/src/core/lib/iomgr/lockfree_event.cc

//
//
// Copyright 2017 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.
//
//

#include <grpc/support/port_platform.h>

#include "src/core/lib/iomgr/lockfree_event.h"

#include <grpc/support/log.h>

#include "src/core/lib/debug/trace.h"
#include "src/core/lib/gprpp/crash.h"
#include "src/core/lib/iomgr/exec_ctx.h"

extern grpc_core::DebugOnlyTraceFlag grpc_polling_trace;

// 'state' holds the to call when the fd is readable or writable respectively.
// It can contain one of the following values:
//   kClosureReady     : The fd has an I/O event of interest but there is no
//                       closure yet to execute

//   kClosureNotReady : The fd has no I/O event of interest

//   closure ptr       : The closure to be executed when the fd has an I/O
//                       event of interest

//   shutdown_error | kShutdownBit :
//                      'shutdown_error' field ORed with kShutdownBit.
//                       This indicates that the fd is shutdown. Since all
//                       memory allocations are word-aligned, the lower two
//                       bits of the shutdown_error pointer are always 0. So
//                       it is safe to OR these with kShutdownBit

// Valid state transitions:

//   <closure ptr> <-----3------ kClosureNotReady -----1------->  kClosureReady
//     |  |                         ^   |    ^                         |  |
//     |  |                         |   |    |                         |  |
//     |  +--------------4----------+   6    +---------2---------------+  |
//     |                                |                                 |
//     |                                v                                 |
//     +-----5------->  [shutdown_error | kShutdownBit] <-------7---------+

//  For 1, 4 : See SetReady() function
//  For 2, 3 : See NotifyOn() function
//  For 5,6,7: See SetShutdown() function

namespace grpc_core {

LockfreeEvent::LockfreeEvent() {}

void LockfreeEvent::InitEvent() {}

void LockfreeEvent::DestroyEvent() {}

void LockfreeEvent::NotifyOn(grpc_closure* closure) {}

bool LockfreeEvent::SetShutdown(grpc_error_handle shutdown_error) {}

void LockfreeEvent::SetReady() {}

}  // namespace grpc_core