PDA

View Full Version : نصب و استفاده از threadpool



program33r
پنج شنبه 17 اسفند 1391, 12:16 عصر
من یه کتابخونه‌ی قابل portable و سبک برای ویندوز و لینوکس میخوام .

از موراد های بسیاری مثل کتابخونه های boost استفاده کردم ولی هر کدومشو نصبش کلی مشکلات داره و هزار جور ارور میده . بعضی هاشون که کلا به جز ویندوز جای دیگه ای اجرا نمیشه

در نهایت به تنها گزینه مناسب که رسیدم threadpool از سایت زیره که از کتابخونه های boost استفاده میکنه
من تمام موارد زیرو انجام دادم ولی بازم ارور میده !!!!
از visual studio 2012 استفاده میکنم /.
چطور من اینو نصبش کنم ؟؟
در ضمن حتما باید boost_1_37_0 دانلود بشه نمیشه از boost_1_53_0 استفاده کرد ؟

http://threadpool.sourceforge.net/


Installing & Using threadpool

threadpool consists only of header files, and so there is no need to build the library itself before using it in your own applications. You simply need to add the following directories to your compiler include path:
threadpool's include directory
the boost directory (e.g. the one called boost_1_37_0)
Furthermore you have to compile boost's thread library and link against it (libboost_thread-*.lib under Windows).

program33r
پنج شنبه 17 اسفند 1391, 12:53 عصر
#include <threadpool.hpp>
#include <iostream>

using namespace std;
using namespace boost::threadpool;

void first_task()
{
for(int i = 1 ; i < 10 ; i++)
{
cout << "first_task";
}
}

void second_task()
{
for(int i = 1 ; i < 10 ; i++)
{
cout << "second_task";
}
}

void third_task()
{
for(int i = 1 ; i < 10 ; i++)
{
cout << "third_task";
}
}

void execute_with_threadpool()
{
pool tp(2);
tp.schedule(&first_task);
tp.schedule(&second_task);
tp.schedule(&third_task);
}

void main()
{
execute_with_threadpool();
}
اینم نتیجه
101053

سرچ کردم این جواب اومد چطور build type رو در visual studio مشخص کنم ؟


If you don't specify "--build-type=" on the command line, the default is to a minimal release build. Try "--build-type=complete".