i'm using asynchronous agent library to implement simple image processing pipeline i have three agents
- CLoadBitmapAgent
- CConvertToGrayAgent
- CSaveBitmapAgent
every run() function as follow
void CLoadBitmapAgent::run()
{
Bitmap *pSourceBitmap = new Bitmap(m_imagePath);
asend(m_target,pSourceBitmap);
done();
}
void CConvertToGrayAgent::run()
{
BitmapUtilities bitmapUtilities;
Bitmap *pSourceBitmap = receive(m_source);
bitmapUtilities.ParallelConvertToGray(pSourceBitmap);
asend(m_target,pSourceBitmap);
done();
}
void CSaveBitmapAgent::run()
{
Bitmap * bitmap = receive(m_source);
BitmapUtilities bitmapUtilities;
CLSID clsid;
bitmapUtilities.GetEncoderClsid(L"image/jpeg",clsid);
bitmap->Save(L"D:\\final_image.jpg",&clsid);
done();
}
and this my code to test this pipeline
wchar_t * wcs = L"D:\\Photos\\z.jpg";
unbounded_buffer<Bitmap*> buffer1;
unbounded_buffer<Bitmap*> buffer2;
CLoadBitmapAgent loadBitmapAgent(wcs,buffer1);
CConvertToGrayAgent convertToGrayAgent(buffer1,buffer2);
CSaveBitmapAgent saveBitmapAgent(buffer2);
loadBitmapAgent.start();
convertToGrayAgent.start();
saveBitmapAgent.start();
agent * agents[3] = {&loadBitmapAgent,&convertToGrayAgent,&saveBitmapAgent};
agent::wait_for_all(4,agents);
the problem is i get access violation exception in this line agent::wait_for_all(4,agents); what causes this exception and how can i fix it thank you