Hello all,
I have a class called Wheel, and I created a boost shared_ptr to this class in the following way:
I also have a vector of these shared_ptr's to Wheels as so:Code:typedef boost::shared_ptr<Wheel> WheelPtr;
In the wheel class I have a variable called "flat" which is initialized to true.Code:vector<WheelPtr> wheels;
I have one thread that keeps iterating through the list looking for flat wheels like so:
In another thread I am constantly doing something else to the wheels. What I have noticed is that when I execute the line:Code:vector<WheelPtr>::iterator it; for(it=wheels.begin(); it!=wheels.end();) { if(!(*it)->Flat()) { (*it) = WheelPtr(); // set to NULL here it=wheels.erase(it); } else it++; }
in the debugger the handle is 0x00000000. But in my other thread the handle is something else like 0x00104f08.Code:(*it) = WheelPtr(); // set to NULL here
Why is the shared_ptr not NULL in the other thread?
Regards,
Ellay K.




Reply With Quote