forked from OSchip/llvm-project
Revert "Use ThreadLauncher to launch TaskPool threads"
This reverts commit r313537 because it fails to link on linux buildbots llvm-svn: 313539
This commit is contained in:
parent
8a0b40a8b3
commit
25c6d26131
|
@ -8,7 +8,6 @@
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
#include "lldb/Utility/TaskPool.h"
|
#include "lldb/Utility/TaskPool.h"
|
||||||
#include "lldb/Host/ThreadLauncher.h"
|
|
||||||
|
|
||||||
#include <cstdint> // for uint32_t
|
#include <cstdint> // for uint32_t
|
||||||
#include <queue> // for queue
|
#include <queue> // for queue
|
||||||
|
@ -24,8 +23,6 @@ public:
|
||||||
private:
|
private:
|
||||||
TaskPoolImpl();
|
TaskPoolImpl();
|
||||||
|
|
||||||
static lldb::thread_result_t WorkerPtr(void *pool);
|
|
||||||
|
|
||||||
static void Worker(TaskPoolImpl *pool);
|
static void Worker(TaskPoolImpl *pool);
|
||||||
|
|
||||||
std::queue<std::function<void()>> m_tasks;
|
std::queue<std::function<void()>> m_tasks;
|
||||||
|
@ -48,7 +45,6 @@ TaskPoolImpl::TaskPoolImpl() : m_thread_count(0) {}
|
||||||
|
|
||||||
void TaskPoolImpl::AddTask(std::function<void()> &&task_fn) {
|
void TaskPoolImpl::AddTask(std::function<void()> &&task_fn) {
|
||||||
static const uint32_t max_threads = std::thread::hardware_concurrency();
|
static const uint32_t max_threads = std::thread::hardware_concurrency();
|
||||||
const size_t min_stack_size = 8 * 1024 * 1024;
|
|
||||||
|
|
||||||
std::unique_lock<std::mutex> lock(m_tasks_mutex);
|
std::unique_lock<std::mutex> lock(m_tasks_mutex);
|
||||||
m_tasks.emplace(std::move(task_fn));
|
m_tasks.emplace(std::move(task_fn));
|
||||||
|
@ -58,17 +54,10 @@ void TaskPoolImpl::AddTask(std::function<void()> &&task_fn) {
|
||||||
// This prevents the thread
|
// This prevents the thread
|
||||||
// from exiting prematurely and triggering a linux libc bug
|
// from exiting prematurely and triggering a linux libc bug
|
||||||
// (https://sourceware.org/bugzilla/show_bug.cgi?id=19951).
|
// (https://sourceware.org/bugzilla/show_bug.cgi?id=19951).
|
||||||
lldb_private::ThreadLauncher::LaunchThread("task-pool.worker", WorkerPtr,
|
std::thread(Worker, this).detach();
|
||||||
this, nullptr, min_stack_size)
|
|
||||||
.Release();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
lldb::thread_result_t TaskPoolImpl::WorkerPtr(void *pool) {
|
|
||||||
Worker((TaskPoolImpl *)pool);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void TaskPoolImpl::Worker(TaskPoolImpl *pool) {
|
void TaskPoolImpl::Worker(TaskPoolImpl *pool) {
|
||||||
while (true) {
|
while (true) {
|
||||||
std::unique_lock<std::mutex> lock(pool->m_tasks_mutex);
|
std::unique_lock<std::mutex> lock(pool->m_tasks_mutex);
|
||||||
|
|
Loading…
Reference in New Issue