summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/clangd/TUScheduler.h
diff options
context:
space:
mode:
authorIlya Biryukov <ibiryukov@google.com>2018-02-08 07:37:35 +0000
committerIlya Biryukov <ibiryukov@google.com>2018-02-08 07:37:35 +0000
commit7e5ee26d1ae40ecd4966e2142ea1ea7c246becbe (patch)
treeae5cff464ca145a396e1b9cd1aaaeda24780d31e /clang-tools-extra/clangd/TUScheduler.h
parentd3704f67adb6f6eb67c9a84e0092e9a89b5864c7 (diff)
downloadbcm5719-llvm-7e5ee26d1ae40ecd4966e2142ea1ea7c246becbe.tar.gz
bcm5719-llvm-7e5ee26d1ae40ecd4966e2142ea1ea7c246becbe.zip
Resubmit "[clangd] The new threading implementation"
Initially submitted as r324356 and reverted in r324386. This change additionally contains a fix to crashes of the buildbots. The source of the crash was undefined behaviour caused by std::future<> whose std::promise<> was destroyed without calling set_value(). llvm-svn: 324575
Diffstat (limited to 'clang-tools-extra/clangd/TUScheduler.h')
-rw-r--r--clang-tools-extra/clangd/TUScheduler.h25
1 files changed, 14 insertions, 11 deletions
diff --git a/clang-tools-extra/clangd/TUScheduler.h b/clang-tools-extra/clangd/TUScheduler.h
index c7df8c4dba1..c984b711209 100644
--- a/clang-tools-extra/clangd/TUScheduler.h
+++ b/clang-tools-extra/clangd/TUScheduler.h
@@ -11,9 +11,9 @@
#define LLVM_CLANG_TOOLS_EXTRA_CLANGD_TUSCHEDULER_H
#include "ClangdUnit.h"
-#include "ClangdUnitStore.h"
#include "Function.h"
#include "Threading.h"
+#include "llvm/ADT/StringMap.h"
namespace clang {
namespace clangd {
@@ -42,6 +42,7 @@ class TUScheduler {
public:
TUScheduler(unsigned AsyncThreadsCount, bool StorePreamblesInMemory,
ASTParsedCallback ASTCallback);
+ ~TUScheduler();
/// Returns estimated memory usage for each of the currently open files.
/// The order of results is unspecified.
@@ -55,12 +56,8 @@ public:
OnUpdated);
/// Remove \p File from the list of tracked files and schedule removal of its
- /// resources. \p Action will be called when resources are freed.
- /// If an error occurs during processing, it is forwarded to the \p Action
- /// callback.
- /// FIXME(ibiryukov): the callback passed to this function is not used, we
- /// should remove it.
- void remove(PathRef File, UniqueFunction<void(llvm::Error)> Action);
+ /// resources.
+ void remove(PathRef File);
/// Schedule an async read of the AST. \p Action will be called when AST is
/// ready. The AST passed to \p Action refers to the version of \p File
@@ -81,11 +78,17 @@ public:
UniqueFunction<void(llvm::Expected<InputsAndPreamble>)> Action);
private:
- const ParseInputs &getInputs(PathRef File);
+ /// This class stores per-file data in the Files map.
+ struct FileData;
- llvm::StringMap<ParseInputs> CachedInputs;
- CppFileCollection Files;
- ThreadPool Threads;
+ const bool StorePreamblesInMemory;
+ const std::shared_ptr<PCHContainerOperations> PCHOps;
+ const ASTParsedCallback ASTCallback;
+ Semaphore Barrier;
+ llvm::StringMap<std::unique_ptr<FileData>> Files;
+ // None when running tasks synchronously and non-None when running tasks
+ // asynchronously.
+ llvm::Optional<AsyncTaskRunner> Tasks;
};
} // namespace clangd
} // namespace clang
OpenPOWER on IntegriCloud