
14 Mar
2010
14 Mar
'10
1:25 a.m.
struct A{ public: A(){ // (1) boost::thread(bind(&A::start,this)).swap(this->thr); } void start(){ ... } private: boost::thread thr; };
ptr_vector<A> avec;
(1) you could also construct A::thr upfront, but some compilers generate warnings if the "this"-pointer is used in member initializers
But I am not going to be able to call, say, avec.front().interrupt(), or avec.front().join() from outside the class this way. Another thing, how about doing just: thr = boost::thread(bind(&A::start, this)); I think you had to swap in earlier versions of the library. Is assignment more efficient than swap in the newer ones? If I have boost::thread as one of the bases no swaps or assignments are needed btw...