|
Boost Users : |
Subject: Re: [Boost-users] Boost.Thread idiom
From: anony (janezz55_at_[hidden])
Date: 2010-03-13 21:25:06
> 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...
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net