OClCollMeshEngn: Use shouldAcceptRequests stop/finalize() pattern

This makes the stop() method capable of synchronously stopping all
engine/server-type async services which don't act in a self-moved
fashion but instead wait for a request.
This commit is contained in:
2025-11-14 01:41:03 -04:00
parent 324e3d1f6a
commit a1625eb562
2 changed files with 86 additions and 36 deletions
@@ -13,6 +13,7 @@
#include <CL/cl.h>
#include <asynchronousLoop.h>
#include <callback.h>
#include <spinLock.h>
#include <user/stimulusFrame.h>
#include "stagingBuffer.h"
#include "frameAssemblyDesc.h"
@@ -59,9 +60,9 @@ private:
StagingBuffer& assemblyBuff, StagingBuffer& collationBuff,
collateKernelCbFn callback);
void stopCompactKernel();
void stopCollateKernel();
void stop();
void compactKernelComplete();
void collateKernelComplete();
bool stop();
public:
// Get kernel execution durations in milliseconds
@@ -80,16 +81,15 @@ private:
cl_program collateProgram;
cl_kernel slotCompactorKernel;
cl_kernel collateKernel;
bool isSetup;
// OpenCL buffers
cl_mem clAssemblyBuffer;
cl_mem clCollationBuffer;
// State tracking
bool compactIsSetup;
SpinLock shouldAcceptRequestsLock;
bool shouldAcceptRequests;
bool compactIsRunning;
bool collateIsSetup;
bool collateIsRunning;
cl_event currentCompactKernelEvent;
cl_event currentCollateKernelEvent;
@@ -155,15 +155,8 @@ private:
size_t globalWorkSize,
void (CL_CALLBACK *eventCallback)(cl_event, cl_int, void*),
const char* kernelName,
bool& isSetup,
bool& isRunning)
{
if (!isSetup)
{
std::cerr << __func__ << ": engine not set up" << std::endl;
return false;
}
if (isRunning)
{
std::cerr << __func__ << ": already running, call stop() first"