IoUringAssmEngn: Implement shouldAcceptRequests daemon/async control

We've reworked the synchronous control functions that govern the
async daemon and in-flight requests for this class. The
shouldAcceptRequests flag represents the readiness state of the
whole engine class. The in-flight async operations consult the
shouldAcceptRequests flag to determine whether they should return
early.

Now the stop() method is solely for setting the locked flag
shouldAcceptRequests=false.

The pair resetAndAssembleFrame()/assemblyCycleComplete manage the
per-assembly cycle state machine, and they don't need to set or
interfere with the shouldAcceptRequests flag.
This commit is contained in:
2025-11-13 23:53:31 -04:00
parent 501effe6d5
commit 1df43665c3
2 changed files with 105 additions and 73 deletions
@@ -47,9 +47,10 @@ public:
{ return nSucceeded != 0 && nTotal != 0 && nSucceeded != nTotal; }
private:
typedef std::function<void(void*, int)> resetAndAssembleFrameCbFn;
typedef std::function<void(void*, int, bool&)> resetAndAssembleFrameCbFn;
void resetAndAssembleFrame(resetAndAssembleFrameCbFn onCqeReady);
void stop(bool doAcquireLock = true);
void assemblyCycleComplete();
bool stop();
private:
PcloudStimulusBuffer& parent;
@@ -59,7 +60,6 @@ private:
// io_uring infrastructure
struct io_uring ring;
bool isSetup;
// Eventfd for CQE notifications (used with boost's unified loop)
int eventfdFd;
@@ -72,12 +72,13 @@ private:
boost::asio::deadline_timer stallTimer;
// Callback for CQE ntfns (called with user_data+result from each CQE)
resetAndAssembleFrameCbFn onCqeReadyCallback;
// Flag to indicate assembly is in progress (cleared by stop())
// Protected by isAssemblingLock
SpinLock isAssemblingLock;
bool isAssembling;
/** EXPLANATION:
* Flag to indicate whether engine should accept new requests.
* Set by setup(), cleared by stop().
*/
SpinLock shouldAcceptRequestsLock;
bool shouldAcceptRequests;
// Number of datagrams per staging buffer frame
size_t nDgramsPerStagingBufferFrame;
struct SlotAssemblyDesc