1

非同期エージェント ライブラリを使用して、単純な画像処理パイプラインを実装しています。3 つのエージェントがあります。

  1. CLoadBitmapAgent
  2. CConvertToGrayAgent
  3. CSaveBitmapAgent

以下のすべての run() 関数

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();
}

そして、これはこのパイプラインをテストするための私のコードです

    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);

問題は、この行でアクセス違反の例外が発生することです。 agent::wait_for_all(4,agents); この例外の原因と、どうすれば修正できますか ありがとう

4

0 に答える 0