The HDK docs makes it seem like multithreading with is really only something you do when writing class methods.
Is there a different approach to running multithreaded code in inline C++? Would it make sense to use an external library like taskflow [github.com] to do the threading instead of using one of houdini's built in libraries, if we want to do threading with just a single function?
Yes, I know VEX can handle the multithreading for you in the virtual machine, but I'm curious about this subject, so entertain me.
void wave(GU_Detail *gdp, float period, float phase, float amp) { tf::Executor executor; tf::Taskflow taskflow; // Collect points to process UT_Array<GA_Offset> offsets; GA_Offset ptoff; GA_FOR_ALL_PTOFF(gdp, ptoff) { offsets.append(ptoff); } // Multi-threaded for_each using Taskflow taskflow.for_each(offsets.begin(), offsets.end(), [=](GA_Offset ptoff) { UT_Vector3 p = gdp->getPos3(ptoff); p.y() += SYSsin((p.x() / period + phase) * M_PI * 2) * amp; gdp->setPos3(ptoff, p); }); executor.run(taskflow).wait(); } [/code]