在boost thread_group中遇到SIGABRT问题

时间:2014-10-30 20:37:50

标签: c++ multithreading gcc boost

我在boost :: thread_group

中遇到了麻烦
boost::asio::io_service ioService;
boost::thread_group threadpool;

boost::asio::io_service::work work(ioService);


for (int i = 0; i  < num_threads; i++) {
    threadpool.create_thread(boost::bind(&boost::asio::io_service::run, &ioService));
}

boost::thread *t_proxy = 0;

if (!without_proxy)
{
    t_proxy = new boost::thread(boost::bind(&ThreadPool::w_proxy, this, proxy_link));
}


int task_size = tasks.size();
for (int i = 0; i < task_size; i++) {
    boost::mutex::scoped_lock lock(_mutex);
    working_threads++;

    ioService.post(boost::bind(&ThreadPool::thread_worker, this));
    tasks.pop_front();


ioService.stop();


if (t_proxy)
{
    t_proxy->join();
}

threadpool.join_all();

&ThreadPool::w_proxy - thread,它在后台检查代理并将其保存到公共列表中 &ThreadPool::thread_worker - worker函数,它使用公共列表中的代理并执行某些功能 任务矢量与任务列表 _mutex - boost :: mutex用于同步代理列表和thread_worker结果 麻烦点: 在进程中,我在字符串中得到了一个SIGABRT t_proxy-&GT;加入(); 或者在 threadpool.join_all();

我试图在一般的thread_group中添加w_proxy,我遇到了同样的麻烦 threadpool.join_all();

我在 condition_variable.hpp 中有回溯 失败的函数是condition_variable::wait

res = pthread_cond_wait(&cond,&internal_mutex);
你可以帮我吗?

0 个答案:

没有答案