From b9c1b51e45b845debb76d8658edabca70ca56079 Mon Sep 17 00:00:00 2001 From: Kate Stone Date: Tue, 6 Sep 2016 20:57:50 +0000 Subject: =?UTF-8?q?***=20This=20commit=20represents=20a=20complete=20refor?= =?UTF-8?q?matting=20of=20the=20LLDB=20source=20code=20***=20to=20conform?= =?UTF-8?q?=20to=20clang-format=E2=80=99s=20LLVM=20style.=20=20This=20kind?= =?UTF-8?q?=20of=20mass=20change=20has=20***=20two=20obvious=20implication?= =?UTF-8?q?s:?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Firstly, merging this particular commit into a downstream fork may be a huge effort. Alternatively, it may be worth merging all changes up to this commit, performing the same reformatting operation locally, and then discarding the merge for this particular commit. The commands used to accomplish this reformatting were as follows (with current working directory as the root of the repository): find . \( -iname "*.c" -or -iname "*.cpp" -or -iname "*.h" -or -iname "*.mm" \) -exec clang-format -i {} + find . -iname "*.py" -exec autopep8 --in-place --aggressive --aggressive {} + ; The version of clang-format used was 3.9.0, and autopep8 was 1.2.4. Secondly, “blame” style tools will generally point to this commit instead of a meaningful prior commit. There are alternatives available that will attempt to look through this change and find the appropriate prior commit. YMMV. llvm-svn: 280751 --- lldb/source/Utility/TaskPool.cpp | 102 ++++++++++++++++----------------------- 1 file changed, 42 insertions(+), 60 deletions(-) (limited to 'lldb/source/Utility/TaskPool.cpp') diff --git a/lldb/source/Utility/TaskPool.cpp b/lldb/source/Utility/TaskPool.cpp index c5c63a2..f66f7bf 100644 --- a/lldb/source/Utility/TaskPool.cpp +++ b/lldb/source/Utility/TaskPool.cpp @@ -9,81 +9,63 @@ #include "lldb/Utility/TaskPool.h" -namespace -{ - class TaskPoolImpl - { - public: - static TaskPoolImpl& - GetInstance(); +namespace { +class TaskPoolImpl { +public: + static TaskPoolImpl &GetInstance(); - void - AddTask(std::function&& task_fn); + void AddTask(std::function &&task_fn); - private: - TaskPoolImpl(); +private: + TaskPoolImpl(); - static void - Worker(TaskPoolImpl* pool); + static void Worker(TaskPoolImpl *pool); - std::queue> m_tasks; - std::mutex m_tasks_mutex; - uint32_t m_thread_count; - }; + std::queue> m_tasks; + std::mutex m_tasks_mutex; + uint32_t m_thread_count; +}; } // end of anonymous namespace -TaskPoolImpl& -TaskPoolImpl::GetInstance() -{ - static TaskPoolImpl g_task_pool_impl; - return g_task_pool_impl; +TaskPoolImpl &TaskPoolImpl::GetInstance() { + static TaskPoolImpl g_task_pool_impl; + return g_task_pool_impl; } -void -TaskPool::AddTaskImpl(std::function&& task_fn) -{ - TaskPoolImpl::GetInstance().AddTask(std::move(task_fn)); +void TaskPool::AddTaskImpl(std::function &&task_fn) { + TaskPoolImpl::GetInstance().AddTask(std::move(task_fn)); } -TaskPoolImpl::TaskPoolImpl() : - m_thread_count(0) -{ -} +TaskPoolImpl::TaskPoolImpl() : m_thread_count(0) {} -void -TaskPoolImpl::AddTask(std::function&& task_fn) -{ - static const uint32_t max_threads = std::thread::hardware_concurrency(); +void TaskPoolImpl::AddTask(std::function &&task_fn) { + static const uint32_t max_threads = std::thread::hardware_concurrency(); - std::unique_lock lock(m_tasks_mutex); - m_tasks.emplace(std::move(task_fn)); - if (m_thread_count < max_threads) - { - m_thread_count++; - // Note that this detach call needs to happen with the m_tasks_mutex held. This prevents the thread - // from exiting prematurely and triggering a linux libc bug - // (https://sourceware.org/bugzilla/show_bug.cgi?id=19951). - std::thread (Worker, this).detach(); - } + std::unique_lock lock(m_tasks_mutex); + m_tasks.emplace(std::move(task_fn)); + if (m_thread_count < max_threads) { + m_thread_count++; + // Note that this detach call needs to happen with the m_tasks_mutex held. + // This prevents the thread + // from exiting prematurely and triggering a linux libc bug + // (https://sourceware.org/bugzilla/show_bug.cgi?id=19951). + std::thread(Worker, this).detach(); + } } -void -TaskPoolImpl::Worker(TaskPoolImpl* pool) -{ - while (true) - { - std::unique_lock lock(pool->m_tasks_mutex); - if (pool->m_tasks.empty()) - { - pool->m_thread_count--; - break; - } +void TaskPoolImpl::Worker(TaskPoolImpl *pool) { + while (true) { + std::unique_lock lock(pool->m_tasks_mutex); + if (pool->m_tasks.empty()) { + pool->m_thread_count--; + break; + } - std::function f = pool->m_tasks.front(); - pool->m_tasks.pop(); - lock.unlock(); + std::function f = pool->m_tasks.front(); + pool->m_tasks.pop(); + lock.unlock(); - f(); - } + f(); + } } -- cgit v1.1