the default pool thread number is thread hw concurrency
This commit is contained in:
parent
e0ba1c7d8a
commit
e8e7ad543c
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* A Thread Pool Implementation
|
||||
* Copyright(C) 2003-2016 Jinhao(cnjinhao@hotmail.com)
|
||||
* Copyright(C) 2003-2018 Jinhao(cnjinhao@hotmail.com)
|
||||
*
|
||||
* Distributed under the Boost Software License, Version 1.0.
|
||||
* (See accompanying file LICENSE_1_0.txt or copy at
|
||||
@ -13,10 +13,14 @@
|
||||
#ifndef NANA_THREADS_POOL_HPP
|
||||
#define NANA_THREADS_POOL_HPP
|
||||
|
||||
#include <nana/c++defines.hpp>
|
||||
#include <nana/traits.hpp>
|
||||
#include <functional>
|
||||
#include <cstddef>
|
||||
|
||||
#ifndef STD_THREAD_NOT_SUPPORTED
|
||||
# include <thread>
|
||||
#endif
|
||||
|
||||
namespace nana{
|
||||
/// Some mutex classes for synchronizing.
|
||||
@ -58,9 +62,12 @@ namespace threads
|
||||
pool(const pool&) = delete;
|
||||
pool& operator=(const pool&) = delete;
|
||||
public:
|
||||
pool(); ///< Creates a group of threads.
|
||||
#ifndef STD_THREAD_NOT_SUPPORTED
|
||||
pool(unsigned thread_number = std::thread::hardware_concurrency()); ///< Creates a group of threads.
|
||||
#else
|
||||
pool(unsigned thread_number = 0);
|
||||
#endif
|
||||
pool(pool&&);
|
||||
pool(std::size_t thread_number); ///< Creates a number of threads specifed by thread_number.
|
||||
~pool(); ///< waits for the all running tasks till they are finished and skips all the queued tasks.
|
||||
|
||||
pool& operator=(pool&&);
|
||||
|
@ -2086,7 +2086,7 @@ namespace nana{ namespace widgets
|
||||
|
||||
void text_editor::copy() const
|
||||
{
|
||||
//Stops copying text if the text_editor is masked.
|
||||
//Disallows copying text if the text_editor is masked.
|
||||
if (mask_char_)
|
||||
return;
|
||||
|
||||
|
@ -351,10 +351,17 @@ namespace threads
|
||||
}container_;
|
||||
};//end class impl
|
||||
|
||||
pool::pool()
|
||||
: impl_(new impl(4))
|
||||
#ifndef STD_THREAD_NOT_SUPPORTED
|
||||
pool::pool(unsigned thread_number)
|
||||
: impl_(new impl(thread_number ? thread_number : std::thread::hardware_concurrency()))
|
||||
{
|
||||
}
|
||||
#else
|
||||
pool::pool(unsigned thread_number)
|
||||
: impl_(new impl(0))
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
pool::pool(pool&& other)
|
||||
: pool()
|
||||
@ -362,11 +369,6 @@ namespace threads
|
||||
std::swap(impl_, other.impl_);
|
||||
}
|
||||
|
||||
pool::pool(std::size_t thread_number)
|
||||
: impl_(new impl(thread_number))
|
||||
{
|
||||
}
|
||||
|
||||
pool& pool::operator=(pool&& other)
|
||||
{
|
||||
if(this != &other)
|
||||
|
Loading…
x
Reference in New Issue
Block a user