> not thread safe if the involved profiles are file-based it still crashes if I use USE_PTHREADS and cmsOpenProfileFromMem()
my reason for wanting to do this, is that cmsCreateTransform() can be quite slow (as much as 1sec), and I often want to make multiple transforms. note, if I use cmsCreate_sRGBProfile() instead of cmsOpenProfileFromXXX(), it doesn't crash Louis Solomon www.SteelBytes.com ----- Original Message ----- From: "Marti.Maria" <[EMAIL PROTECTED]> To: "Louis Solomon [SteelBytes]" <[EMAIL PROTECTED]>; "lcms-user" <lcms-user@lists.sourceforge.net> Sent: Thursday, June 07, 2007 6:08 PM Subject: Re: [Lcms-user] cmsCreateTransform is not thread safe > > > Hi Louis, > > Thanks for the report. Yes, you are right, cmsCreateTransform > is not thread safe if the involved profiles are file-based. That is > because files are not locked when readed. Currently, only > cmsDoTransform() is thread safe, and strictly you have to > turn on USE_PTHREADS toggle on lcms.h > > That is so because multithreading only make real sense when > applying rerendering. But your point is well taken, and locking the > file would be an interesting addition for next release, unfortunately > not for 1.17 since I am already out of schedule. > > Thanks again. > Marti > > ----- Original Message ----- > From: "Louis Solomon [SteelBytes]" <[EMAIL PROTECTED]> > To: "lcms-user" <lcms-user@lists.sourceforge.net> > Sent: Tuesday, June 05, 2007 8:13 AM > Subject: [Lcms-user] cmsCreateTransform is not thread safe > > > Hi, > cmsCreateTransform is not thread safe using 1.16 or 1.17b. Note, using > cmsCreate_sRGBProfile() instead of > cmsOpenProfileFromFile("AdobeRGB1998.icc","rb") does work, and so does > calling the two cmsCreateTransform()'s in succession. Test env: 32bit > debug > target built with VS2005 on Vista64. > > Louis Solomon > www.SteelBytes.com > > > #include <windows.h> > #include "lcms\lcms.h" > > static cmsHPROFILE prof_xyz,prof_rgb; > static cmsHTRANSFORM trans_xyz_to_rgb,trans_rgb_to_xyz; > > static DWORD WINAPI make_trans_xyz_to_rgb(LPVOID lpParameter) > { > trans_xyz_to_rgb = cmsCreateTransform( > prof_xyz,TYPE_XYZ_DBL, > prof_rgb,TYPE_RGB_DBL, > INTENT_ABSOLUTE_COLORIMETRIC,cmsFLAGS_NOTPRECALC); > return 0; > } > > static DWORD WINAPI make_trans_rgb_to_xyz(LPVOID lpParameter) > { > trans_rgb_to_xyz = cmsCreateTransform( > prof_rgb,TYPE_RGB_DBL, > prof_xyz,TYPE_XYZ_DBL, > INTENT_ABSOLUTE_COLORIMETRIC,cmsFLAGS_NOTPRECALC); > return 0; > } > > int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR > lpCmdLine,int nCmdShow) > { > prof_xyz = cmsCreateXYZProfile(); > prof_rgb = cmsOpenProfileFromFile("AdobeRGB1998.icc","rb"); > //cmsCreate_sRGBProfile(); > for (int i=0;i<10;++i) > { > #define try_threads > #ifdef try_threads > DWORD threadid; > HANDLE workers[2]; > workers[0] = CreateThread(NULL,0,make_trans_xyz_to_rgb,NULL,0,&threadid); > workers[1] = CreateThread(NULL,0,make_trans_rgb_to_xyz,NULL,0,&threadid); > WaitForMultipleObjects(2,workers,TRUE,INFINITE); > for (unsigned i=0;i<2;++i) > CloseHandle(workers[i]); > #else > make_trans_xyz_to_rgb(0); > make_trans_rgb_to_xyz(0); > #endif > cmsDeleteTransform(trans_xyz_to_rgb); > cmsDeleteTransform(trans_rgb_to_xyz); > } > cmsCloseProfile(prof_rgb); > cmsCloseProfile(prof_xyz); > } > > > ------------------------------------------------------------------------- > This SF.net email is sponsored by DB2 Express > Download DB2 Express C - the FREE version of DB2 express and take > control of your XML. No limits. Just data. Click to get it now. > http://sourceforge.net/powerbar/db2/ > _______________________________________________ > Lcms-user mailing list > Lcms-user@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/lcms-user > > ------------------------------------------------------------------------- This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ _______________________________________________ Lcms-user mailing list Lcms-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/lcms-user