Friday, July 27, 2012

How to run class member function in C++11 thread


class X
{
private:
 int mX;
public:
 F()
 {
   // some work
 }
};

void thread_sample()
{
  X x;
  std::thread th(&X::F,&x);
  th.join(); // call detach() if you want this method not to wait for F() to finish
 }

No comments :

Post a Comment

Friday, July 27, 2012

How to run class member function in C++11 thread


class X
{
private:
 int mX;
public:
 F()
 {
   // some work
 }
};

void thread_sample()
{
  X x;
  std::thread th(&X::F,&x);
  th.join(); // call detach() if you want this method not to wait for F() to finish
 }

No comments :

Post a Comment