开发者

boost thread list

开发者 https://www.devze.com 2023-03-15 13:19 出处:网络
I have code开发者_JS百科 similar to below. The code below gives SIGSEGV and points to list::push_back. Is this the right way to use list of boost threads?

I have code开发者_JS百科 similar to below. The code below gives SIGSEGV and points to list::push_back. Is this the right way to use list of boost threads?

struct mythread{
   static void myfunc() {
      while(1){ }
   }
};

int f(){
   std::list<boost::thread *> pool;
   pool.push_back(new boost::thread(mythread::myfunc));
}

Environment: gcc 4.4.5 on Ubuntu, linked with libboost_thread.a and -lpthread. I am not using c++0x flag.

Regards,

Chubsdad

Note 2: I also get SIGSEGV for the code

pool.push_back(new boost::thread(NULL);


Try taking the address of the function pointer:

pool.push_back(new boost::thread(&mythread::myfunc));
0

精彩评论

暂无评论...
验证码 换一张
取 消