forked from OSchip/llvm-project
parent
c78890640e
commit
37a575f8b6
|
@ -46,7 +46,6 @@ ErrorHandler &lld::errorHandler() {
|
|||
}
|
||||
|
||||
void lld::exitLld(int Val) {
|
||||
waitForBackgroundThreads();
|
||||
// Dealloc/destroy ManagedStatic variables before calling
|
||||
// _exit(). In a non-LTO build, this is a nop. In an LTO
|
||||
// build allows us to get the output of -time-passes.
|
||||
|
|
|
@ -8,25 +8,5 @@
|
|||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "lld/Common/Threads.h"
|
||||
#include <thread>
|
||||
#include <vector>
|
||||
|
||||
static std::vector<std::thread> Threads;
|
||||
|
||||
bool lld::ThreadsEnabled = true;
|
||||
|
||||
// Runs a given function in a new thread.
|
||||
void lld::runBackground(std::function<void()> Fn) {
|
||||
Threads.emplace_back(Fn);
|
||||
}
|
||||
|
||||
// Wait for all threads spawned for runBackground() to finish.
|
||||
//
|
||||
// You need to call this function from the main thread before exiting
|
||||
// because it is not defined what will happen to non-main threads when
|
||||
// the main thread exits.
|
||||
void lld::waitForBackgroundThreads() {
|
||||
for (std::thread &T : Threads)
|
||||
if (T.joinable())
|
||||
T.join();
|
||||
}
|
||||
|
|
|
@ -93,7 +93,6 @@ bool elf::link(ArrayRef<const char *> Args, bool CanExitEarly,
|
|||
Config->Argv = {Args.begin(), Args.end()};
|
||||
|
||||
Driver->main(Args, CanExitEarly);
|
||||
waitForBackgroundThreads();
|
||||
|
||||
// Exit immediately if we don't need to return to the caller.
|
||||
// This saves time because the overhead of calling destructors
|
||||
|
|
|
@ -81,9 +81,6 @@ inline void parallelForEachN(size_t Begin, size_t End,
|
|||
for_each_n(llvm::parallel::seq, Begin, End, Fn);
|
||||
}
|
||||
|
||||
void runBackground(std::function<void()> Fn);
|
||||
void waitForBackgroundThreads();
|
||||
|
||||
} // namespace lld
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue