mirror of
https://gitee.com/fasiondog/hikyuu.git
synced 2024-11-30 02:48:57 +08:00
update thread pool and travis
This commit is contained in:
parent
a41b60fe1d
commit
315a818e4d
@ -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
|
||||
|
||||
|
@ -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) {
|
||||
|
@ -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();
|
||||
});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user