folly/folly/fibers/FiberManagerInternal-inl.h

/*
 * 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.
 */

#pragma once

#include <cassert>

#include <folly/CPortability.h>
#include <folly/Memory.h>
#include <folly/Optional.h>
#include <folly/Portability.h>
#include <folly/ScopeGuard.h>
#include <folly/Try.h>
#include <folly/fibers/Baton.h>
#include <folly/fibers/Fiber.h>
#include <folly/fibers/LoopController.h>
#include <folly/fibers/Promise.h>
#include <folly/tracing/AsyncStack.h>

namespace folly {
namespace fibers {

namespace {

inline FiberManager::Options preprocessOptions(FiberManager::Options opts) {}

template <class F>
FOLLY_NOINLINE invoke_result_t<F> runNoInline(F&& func) {}

template <class Result, class F>
FOLLY_NOINLINE void tryEmplaceWithNoInline(
    folly::Try<Result>& result, F&& func) {}

} // namespace

inline void FiberManager::ensureLoopScheduled() {}

inline void FiberManager::activateFiber(Fiber* fiber) {}

inline void FiberManager::deactivateFiber(Fiber* fiber) {}

inline void FiberManager::runReadyFiber(Fiber* fiber) {}

inline void FiberManager::loopUntilNoReady() {}

template <typename LoopFunc>
void FiberManager::runFibersHelper(LoopFunc&& loopFunc) {}

inline size_t FiberManager::recordStackPosition(size_t position) {}

inline void FiberManager::loopUntilNoReadyImpl() {}

inline void FiberManager::runEagerFiber(Fiber* fiber) {}

inline void FiberManager::runEagerFiberImpl(Fiber* fiber) {}

inline bool FiberManager::shouldRunLoopRemote() {}

inline bool FiberManager::hasReadyTasks() const {}

// We need this to be in a struct, not inlined in addTask, because clang crashes
// otherwise.
template <typename F>
struct FiberManager::AddTaskHelper {};

template <typename F>
Fiber* FiberManager::createTask(F&& func, TaskOptions taskOptions) {}

template <typename F>
void FiberManager::addTask(F&& func, TaskOptions taskOptions) {}

template <typename F>
void FiberManager::addTaskEager(F&& func) {}

template <typename F>
void FiberManager::addTaskRemote(F&& func) {}

template <typename X>
struct IsRvalueRefTry {};
IsRvalueRefTry<folly::Try<T> &&>;

// We need this to be in a struct, not inlined in addTaskFinally, because clang
// crashes otherwise.
template <typename F, typename G>
struct FiberManager::AddTaskFinallyHelper {};

template <typename F, typename G>
Fiber* FiberManager::createTaskFinally(F&& func, G&& finally) {}

template <typename F, typename G>
void FiberManager::addTaskFinally(F&& func, G&& finally) {}

template <typename F, typename G>
void FiberManager::addTaskFinallyEager(F&& func, G&& finally) {}

template <typename F>
invoke_result_t<F> FiberManager::runInMainContext(F&& func) {}

inline FiberManager& FiberManager::getFiberManager() {}

inline FiberManager* FiberManager::getFiberManagerUnsafe() {}

inline bool FiberManager::hasActiveFiber() const {}

inline folly::Optional<std::chrono::nanoseconds>
FiberManager::getCurrentTaskRunningTime() const {}

inline void FiberManager::yield() {}

template <typename T>
T& FiberManager::local() {}

template <typename T>
T& FiberManager::localThread() {}

inline void FiberManager::initLocalData(Fiber& fiber) {}

template <typename LocalT>
FiberManager::FiberManager(
    LocalType<LocalT>,
    std::unique_ptr<LoopController> loopController__,
    Options options)
    : loopController_(std::move(loopController__)),
      stackAllocator_(options.guardPagesPerStack),
      options_(preprocessOptions(std::move(options))),
      exceptionCallback_(defaultExceptionCallback),
      fibersPoolResizer_(*this),
      localType_(typeid(LocalT)) {}

template <typename F>
typename FirstArgOf<F>::type::value_type inline await_async(F&& func) {}

template <typename F>
invoke_result_t<F> inline runInMainContext(F&& func) {}

} // namespace fibers
} // namespace folly