//===--- Cancellation.cpp -----------------------------------------*-C++-*-===// // // The LLVM Compiler Infrastructure // // This file is distributed under the University of Illinois Open Source // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// #include "Cancellation.h" #include namespace clang { namespace clangd { char CancelledError::ID = 0; static Key>> FlagKey; std::pair cancelableTask() { auto Flag = std::make_shared>(); return { Context::current().derive(FlagKey, Flag), [Flag] { *Flag = true; }, }; } bool isCancelled() { if (auto *Flag = Context::current().get(FlagKey)) return **Flag; return false; // Not in scope of a task. } } // namespace clangd } // namespace clang