I was wondering if the following code would be considered thread safe. I think it should be, but I'm not too familiar with what is happening under the hood.
Basically, I have this function in the Foo class, which will be called in the main thread and accepts the vector as anrgument, i.e.
void Foo::func( vector<int> v)
In Foo, I also have a private member,
vector< vector<int> > vecOfVec;
Inside, funcI will just drop any new ones von vecOfVecand check the size v. If it is vsmaller than its expected size, I would like to start another thread that fills with vsome known predefined values, for example:
void Foo::func( vector<int> v)
{
int size = v.size();
int index = vecOfVec.size();
vecOfVec.push_back(v);
if (size < 1000)
{
boost::thread t( boost::bind( &Foo::PushBackZeros, this, vecOfVec, index) );
}
}
Foo::PushBackZeros , 'vecOfVec [index]' , 1000;
vecOfVec. , , vecOfVec.
- , ? STL? , . !