I Just have just getting started to use intels Threading Building Blocks, but it just took some minutes before I got some problem. If I am running the code below will m_type.size() always return 0 even if i am pushing new data in a second thread:
But if I am making m_type to a reference (&) will it work without problems.
Test(tbb::concurrent_vector<std::string> & t)
std::cout << "Producing now..";
if(m_type.size() < 1000)
std::cout << "worker: size = " << m_type.size() << std::endl;
std::cout << "Consuming now..";
std::cout << "Consumer: size = " << m_type.size() << std::endl;
std::string message = m_type.back();
std::cout << "Message: " << message << std::endl;
if(m_type.size() > 100)
int main(int argc, char** argv)
boost::thread thread(boost::bind(&Test::worker, test));
boost::thread thread2(boost::bind(&Test::consumer, test));
I know that local variables can be read into a processor cache and that is what I think happens, but how do I prevent it? And if it isn't the problem, what I am doing wrong then?
I second question:
Do any of you have any good multi threading links to share?
Thanks in advance