From b5826dac78e75520c26f2d84a952fe04d69fa2d3 Mon Sep 17 00:00:00 2001 From: Garrett D'Amore Date: Thu, 26 Dec 2024 12:13:49 -0800 Subject: aio: introduce nni_aio_reset to reset the aio before submitting more work This allows some use cases to reset things like the counts and outputs, before submitting more jobs. Providers should call this near the top of their functions; this is done without any locks so it should be very fast. --- src/core/aio.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/core/aio.h') diff --git a/src/core/aio.h b/src/core/aio.h index b09b6e49..d909853f 100644 --- a/src/core/aio.h +++ b/src/core/aio.h @@ -175,6 +175,11 @@ extern int nni_aio_schedule(nni_aio *, nni_aio_cancel_fn, void *); // or was canceled before this call (but after nni_aio_begin). extern bool nni_aio_defer(nni_aio *, nni_aio_cancel_fn, void *); +// nni_aio_reset is called by providers before doing any work -- it resets +// counts other fields to their initial state. It will not reset the closed +// state if the aio has been stopped or closed. +extern void nni_aio_reset(nni_aio *); + // nni_aio_start should be called before any asynchronous operation // is filed. It need not be called for completions that are synchronous // at job submission. @@ -230,6 +235,7 @@ struct nng_aio { bool a_use_expire; // Use expire instead of timeout bool a_abort; // Task was aborted bool a_init; // Initialized this + bool a_stopped; // Debug - set when we finish stopped nni_task a_task; // Read/write operations. -- cgit v1.2.3-70-g09d2