update thread pool and travis

This commit is contained in:
fasiondog 2019-09-21 21:01:44 +08:00
parent a41b60fe1d
commit 315a818e4d
3 changed files with 26 additions and 6 deletions

View File

@ -38,7 +38,5 @@ script:
- export BOOST_LIB=./boost_1_67_0/stage/lib
- ls .
- xmake f --cxx=$CXX --confirm=y --test=small
- xmake -b hikyuu
- if [ "$CXX_FOR_BUILD" = "clang++" ]; then xmake -b small-test; fi
- if [ "$CXX_FOR_BUILD" = "clang++" ]; then xmake r small-test; fi
- xmake r small-test

View File

@ -53,7 +53,7 @@ public:
template<typename FunctionType>
task_handle<typename std::result_of<FunctionType()>::type> submit(FunctionType f) {
typedef std::result_of<FunctionType()>::type result_type;
typedef typename std::result_of<FunctionType()>::type result_type;
std::packaged_task<result_type()> task(f);
task_handle<result_type> res(task.get_future());
if (m_local_work_queue) {

View File

@ -11,12 +11,34 @@
using namespace hku;
int Fibon(int n) {
int num1 = 1;
int num2 = 1;
int tmp = 0;
int i = 0;
if (n < 3)
{
return 1;
}
else
{
for (i = 0; i <= n-3; i++)
{
tmp = num1 + num2;
num1 = num2;
num2 = tmp;
}
return tmp;
}
}
BOOST_AUTO_TEST_CASE( test_temp ) {
ThreadPool tg;
for (int i = 0; i < 10; i++) {
for (int i = 0; i < 40; i++) {
tg.submit([=]() {
int x = Fibon(i+1);
std::stringstream buf;
buf << i << ": --------------------" << std::endl;
buf << i+1 << ": " << x << std::endl;
std::cout << buf.str();
});
}