1

i'm using asynchronous agent library to implement simple image processing pipeline i have three agents

  1. CLoadBitmapAgent
  2. CConvertToGrayAgent
  3. 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

Ma7moud El-Naggar
  • 548
  • 1
  • 6
  • 18
  • I think GDI+ has a limitation where GDI+ objects have to all be accessed from the same thread... not sure though. – AshleysBrain Jan 27 '12 at 03:34
  • this is not true i have test project define one bitmap object on the main thread and modify it in another thread using call message block (class form asynchronous agents library) – Ma7moud El-Naggar Jan 28 '12 at 01:29
  • @Ma7moudEl-Naggar Since you pass in three agents pointers to `wait_for_all`, why do you pass 4 to array size? This seems to be just a typo. **Voting to close "too localized"**. – rwong Jun 15 '13 at 20:22

0 Answers0