#include <algorithm>
#include <cstdint>
#include <limits>
#include <tuple>
#include <utility>
#include <glog/logging.h>
namespace folly {
namespace detail {
struct FixedMergingCancellationStateTag { … };
class CancellationState { … };
template <size_t N>
class FixedMergingCancellationState : public CancellationState { … };
template <typename... Data>
class CancellationStateWithData : public CancellationState { … };
inline void CancellationStateTokenDeleter::operator()(
CancellationState* state) noexcept { … }
inline void CancellationStateSourceDeleter::operator()(
CancellationState* state) noexcept { … }
}
inline CancellationToken::CancellationToken(
const CancellationToken& other) noexcept
: … { … }
inline CancellationToken::CancellationToken(CancellationToken&& other) noexcept
: … { … }
inline CancellationToken& CancellationToken::operator=(
const CancellationToken& other) noexcept { … }
inline CancellationToken& CancellationToken::operator=(
CancellationToken&& other) noexcept { … }
inline bool CancellationToken::isCancellationRequested() const noexcept { … }
inline bool CancellationToken::canBeCancelled() const noexcept { … }
inline void CancellationToken::swap(CancellationToken& other) noexcept { … }
inline CancellationToken::CancellationToken(
detail::CancellationStateTokenPtr state) noexcept
: … { … }
inline bool operator==(
const CancellationToken& a, const CancellationToken& b) noexcept { … }
inline bool operator!=(
const CancellationToken& a, const CancellationToken& b) noexcept { … }
inline CancellationSource::CancellationSource()
: … { … }
inline CancellationSource::CancellationSource(
const CancellationSource& other) noexcept
: … { … }
inline CancellationSource::CancellationSource(
CancellationSource&& other) noexcept
: … { … }
inline CancellationSource& CancellationSource::operator=(
const CancellationSource& other) noexcept { … }
inline CancellationSource& CancellationSource::operator=(
CancellationSource&& other) noexcept { … }
inline CancellationSource CancellationSource::invalid() noexcept { … }
inline bool CancellationSource::isCancellationRequested() const noexcept { … }
inline bool CancellationSource::canBeCancelled() const noexcept { … }
inline CancellationToken CancellationSource::getToken() const noexcept { … }
inline bool CancellationSource::requestCancellation() const noexcept { … }
inline void CancellationSource::swap(CancellationSource& other) noexcept { … }
inline CancellationSource::CancellationSource(
detail::CancellationStateSourcePtr&& state) noexcept
: … { … }
template <
typename Callable,
std::enable_if_t<
std::is_constructible<CancellationCallback::VoidFunction, Callable>::
value,
int>>
inline CancellationCallback::CancellationCallback(
CancellationToken&& ct, Callable&& callable)
: next_(nullptr),
prevNext_(nullptr),
state_(nullptr),
callback_(static_cast<Callable&&>(callable)),
destructorHasRunInsideCallback_(nullptr),
callbackCompleted_(false) { … }
template <
typename Callable,
std::enable_if_t<
std::is_constructible<CancellationCallback::VoidFunction, Callable>::
value,
int>>
inline CancellationCallback::CancellationCallback(
const CancellationToken& ct, Callable&& callable)
: next_(nullptr),
prevNext_(nullptr),
state_(nullptr),
callback_(static_cast<Callable&&>(callable)),
destructorHasRunInsideCallback_(nullptr),
callbackCompleted_(false) { … }
inline CancellationCallback::~CancellationCallback() { … }
inline void CancellationCallback::invokeCallback() noexcept { … }
namespace detail {
inline CancellationStateSourcePtr CancellationState::create() { … }
inline CancellationState::CancellationState() noexcept
: … { … }
inline CancellationState::CancellationState(
FixedMergingCancellationStateTag) noexcept
: … { … }
inline CancellationStateTokenPtr
CancellationState::addTokenReference() noexcept { … }
inline void CancellationState::removeTokenReference() noexcept { … }
inline CancellationStateSourcePtr
CancellationState::addSourceReference() noexcept { … }
inline void CancellationState::removeSourceReference() noexcept { … }
inline bool CancellationState::isCancellationRequested() const noexcept { … }
inline bool CancellationState::canBeCancelled() const noexcept { … }
inline bool CancellationState::canBeCancelled(std::uint64_t state) noexcept { … }
inline bool CancellationState::isCancellationRequested(
std::uint64_t state) noexcept { … }
inline bool CancellationState::isLocked(std::uint64_t state) noexcept { … }
template <size_t N>
template <typename... Ts>
inline CancellationStateTokenPtr FixedMergingCancellationState<N>::create(
Ts&&... tokens) { … }
template <typename... Data>
struct WithDataTag { … };
template <size_t N>
template <typename... Ts>
inline FixedMergingCancellationState<N>::FixedMergingCancellationState(
Ts&&... tokens)
: CancellationState(FixedMergingCancellationStateTag{ … }
template <typename... Data>
template <typename... Args>
CancellationStateWithData<Data...>::CancellationStateWithData(Args&&... data)
: data_(std::forward<Args>(data)...) { … }
template <typename... Data>
template <typename... Args>
std::pair<CancellationStateSourcePtr, std::tuple<Data...>*>
CancellationStateWithData<Data...>::create(Args&&... data) { … }
inline bool variadicDisjunction() { … }
inline bool variadicDisjunction(bool first) { … }
template <typename... Bools>
bool variadicDisjunction(bool first, Bools... bools) { … }
}
template <typename... Data, typename... Args>
std::pair<CancellationSource, std::tuple<Data...>*> CancellationSource::create(
detail::WithDataTag<Data...>, Args&&... data) { … }
template <typename... Ts>
inline CancellationToken CancellationToken::merge(Ts&&... tokens) { … }
}