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