I have created a future object, as such:
Future.h
#ifndef FUTURE_H_
#define FUTURE_H_
#include "../interfaces/IFuture.h"
#include <stdio.h>
#include <boost/thread.hpp>
using namespace boost;
class Future: public IFuture {
private:
void** data;
bool isDataReady;
mutex mut;
condition_variable cond;
public:
Future();
~Future();
bool isReady();
void setData(void* data[]);
void** getData();
};
#endif /* FUTURE_H_ */
Future.cpp
#include "../headers/Future.h"
Future::Future(){
this->data = NULL;
this->isDataReady = false;
}
Future::~Future(){
delete [] data;
}
bool Future::isReady(){
return isDataReady;
}
void Future::setData(void* data[]){
if(isDataReady)
return;
{
lock_guard<mutex> lock(mut);
this->data = data;
isDataReady = true;
}
cond.notify_one();
}
void** Future::getData(){
unique_lock<mutex> lock(mut);
while(!isDataReady){
cond.wait(lock);
}
return data;
}
The main application creates multiple Future objects as needed. The first object work fine, but around the one-hundredth Future object the condition.wait(mut) fails the BOOST_ASSERT( px != 0 ); in intrusive_ptr.hpp.
I do not understand why this is happening.
I am using boost thread in windows on the mingw g++ compiler.
Problem "fixed". Started using Visual Studio and its compiler. Boost thread and MinGW are not very compatible.