Hi,
Is there any example of some plugin that uses multithreading?
I done multithreading in my object plugin using CreateThread from WinApi,
but the performance was poor, about 10-15 fps less than not using multithreading.
I am pasting part of the code below:
class myClass
{
static DWORD WINAPI ThreadCreate(LPVOID);
DWORD ThreadStart(LPVOID);
void BuildMesh();
}
// struct for arguments
struct myArgs
{
myClass* myclass;
int a, b, c, d;
};
// ----
DWORD WINAPI MyClass::ThreadCreate(LPVOID lParam)
{
myClass* _This = static_cast<myArgs*>(lParam)->myclass
return _This->ThreadStart(lParam);
}
DWORD myClass::ThreadStart(LPVOID lParam)
{
// some code to do in multithreading
int start = static_cast<myArgs*>(lParam)->a;
int end = static_cast<myArgs*>(lParam)->b;
}
void BuildMesh()
{
DWORD ThreadID_1, ThreadID_2;
HANDLE t[2];
t[0] = CreateThread(NULL, 0, ThreadCreate, &a1, 0, &ThreadID_1);
WaitForSingleObject(t[0], INFINITE);
mesh.InvalidateGeomCache();
}