chromium/third_party/grpc/src/src/core/lib/gprpp/fork.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/gprpp/fork.h"

#include <grpc/support/atm.h>
#include <grpc/support/sync.h>
#include <grpc/support/time.h>

#include "src/core/lib/event_engine/thread_local.h"
#include "src/core/lib/gprpp/global_config_env.h"
#include "src/core/lib/gprpp/no_destruct.h"

//
// NOTE: FORKING IS NOT GENERALLY SUPPORTED, THIS IS ONLY INTENDED TO WORK
//       AROUND VERY SPECIFIC USE CASES.
//

#ifdef GRPC_ENABLE_FORK_SUPPORT
#define GRPC_ENABLE_FORK_SUPPORT_DEFAULT
#else
#define GRPC_ENABLE_FORK_SUPPORT_DEFAULT
#endif  // GRPC_ENABLE_FORK_SUPPORT

GPR_GLOBAL_CONFIG_DEFINE_BOOL(grpc_enable_fork_support,
                              GRPC_ENABLE_FORK_SUPPORT_DEFAULT,
                              "Enable fork support");

namespace grpc_core {
namespace {
// The exec_ctx_count has 2 modes, blocked and unblocked.
// When unblocked, the count is 2-indexed; exec_ctx_count=2 indicates
// 0 active ExecCtxs, exex_ctx_count=3 indicates 1 active ExecCtxs...

// When blocked, the exec_ctx_count is 0-indexed.  Note that ExecCtx
// creation can only be blocked if there is exactly 1 outstanding ExecCtx,
// meaning that BLOCKED and UNBLOCKED counts partition the integers
#define UNBLOCKED(n)
#define BLOCKED(n)

class ExecCtxState {};

class ThreadState {};

}  // namespace

void Fork::GlobalInit() {}

bool Fork::Enabled() {}

// Testing Only
void Fork::Enable(bool enable) {}

void Fork::DoIncExecCtxCount() {}

void Fork::DoDecExecCtxCount() {}

void Fork::SetResetChildPollingEngineFunc(
    Fork::child_postfork_func reset_child_polling_engine) {}

const std::vector<Fork::child_postfork_func>&
Fork::GetResetChildPollingEngineFunc() {}

bool Fork::BlockExecCtx() {}

void Fork::AllowExecCtx() {}

void Fork::IncThreadCount() {}

void Fork::DecThreadCount() {}
void Fork::AwaitThreads() {}

std::atomic<bool> Fork::support_enabled_(false);
bool Fork::override_enabled_ =;
std::vector<Fork::child_postfork_func>* Fork::reset_child_polling_engine_ =;
}  // namespace grpc_core