folly/folly/executors/GlobalExecutor.cpp

/*
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * 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 <folly/executors/GlobalExecutor.h>

#include <memory>
#include <thread>

#include <folly/Function.h>
#include <folly/SharedMutex.h>
#include <folly/Singleton.h>
#include <folly/detail/AsyncTrace.h>
#include <folly/executors/CPUThreadPoolExecutor.h>
#include <folly/executors/IOExecutor.h>
#include <folly/executors/IOThreadPoolExecutor.h>
#include <folly/executors/InlineExecutor.h>
#include <folly/system/HardwareConcurrency.h>

usingnamespacefolly;

FOLLY_GFLAGS_DEFINE_uint32();

FOLLY_GFLAGS_DEFINE_uint32();

FOLLY_GFLAGS_DEFINE_bool();

FOLLY_GFLAGS_DEFINE_uint32();

namespace {

ImmutableGlobalCPUExecutor;

class GlobalTag {};

// aka InlineExecutor
class DefaultCPUExecutor : public InlineLikeExecutor {};

Singleton<std::shared_ptr<DefaultCPUExecutor>> gDefaultGlobalCPUExecutor([] {});

Singleton<std::shared_ptr<ImmutableGlobalCPUExecutor>, GlobalTag>
    gImmutableGlobalCPUExecutor([] {});

Singleton<std::shared_ptr<IOThreadPoolExecutor>, GlobalTag>
    gImmutableGlobalIOExecutor([] {});

template <class ExecutorBase>
std::shared_ptr<ExecutorBase> getImmutable();

template <>
std::shared_ptr<Executor> getImmutable() {}

template <>
std::shared_ptr<IOExecutor> getImmutable() {}

template <class ExecutorBase>
class GlobalExecutor {};

LeakySingleton<GlobalExecutor<Executor>> gGlobalCPUExecutor([] {});

LeakySingleton<GlobalExecutor<IOExecutor>> gGlobalIOExecutor([] {});
} // namespace

namespace folly {

namespace detail {
std::shared_ptr<Executor> tryGetImmutableCPUPtr() {}
} // namespace detail

Executor::KeepAlive<> getGlobalCPUExecutor() {}

Executor::KeepAlive<> getGlobalCPUExecutorWeakRef() {}

GlobalCPUExecutorCounters getGlobalCPUExecutorCounters() {}

Executor::KeepAlive<IOExecutor> getGlobalIOExecutor() {}

std::shared_ptr<Executor> getUnsafeMutableGlobalCPUExecutor() {}

std::shared_ptr<Executor> getCPUExecutor() {}

void setUnsafeMutableGlobalCPUExecutorToGlobalCPUExecutor() {}

void setCPUExecutorToGlobalCPUExecutor() {}

void setUnsafeMutableGlobalCPUExecutor(std::weak_ptr<Executor> executor) {}

void setCPUExecutor(std::weak_ptr<Executor> executor) {}

std::shared_ptr<IOExecutor> getUnsafeMutableGlobalIOExecutor() {}

std::shared_ptr<IOExecutor> getIOExecutor() {}

void setUnsafeMutableGlobalIOExecutor(std::weak_ptr<IOExecutor> executor) {}

void setIOExecutor(std::weak_ptr<IOExecutor> executor) {}

EventBase* getUnsafeMutableGlobalEventBase() {}

EventBase* getEventBase() {}

} // namespace folly