38#define REACTOR_TESTS(X) \
39 X("reactor::lifecycle", test_reactor_lifecycle), \
40 X("reactor::activate_shutdown", test_reactor_activate_shutdown), \
41 X("reactor::fresh_state", test_reactor_fresh_state), \
42 X("reactor::nop_roundtrip", test_reactor_nop_roundtrip), \
43 X("reactor::channel_routing", test_reactor_channel_routing), \
44 X("reactor::cq_spsc_stress", test_reactor_cq_spsc_stress), \
45 X("reactor::sleep", test_reactor_sleep)
188 size_t sent = 0, got = 0;
195 bool progress =
false;
#define TEST_ASSERT(cond)
Internal reactor backend interface.
#define SHUTDOWN_ENGINE(mm, engine)
#define MAKE_ENGINE(mm, engine)
AI Generated (🤦) Fiber subsystem overview.
void srn_reactor_activate(srn_reactor_t *reactor, size_t nchannels, srn_reactor_notify_fn notify)
Bring the reactor up, allocate nchannels channels (one per worker) and start the reactor thread.
void srn_reactor_op_done(srn_reactor_t *reactor, size_t channel)
Drop channel's and the reactor's in-flight counts by one.
size_t srn_reactor_reap(srn_reactor_t *reactor, size_t channel, srn_reactor_io_completion_t *out, size_t max)
Drain up to max completions from channel's completion queue into out, returning how many were taken.
bool srn_reactor_idle(srn_reactor_t *reactor)
Whether the reactor has no operations in flight.
bool srn_reactor_channel_has_completions(srn_reactor_t *reactor, size_t channel)
Whether channel's completion queue has unconsumed completions.
bool srn_reactor_submit(srn_reactor_t *reactor, size_t channel, const srn_reactor_io_request_t *request)
Place a request on channel's submission queue and rouse the reactor.
@ SRN_REACTOR_IO_SLEEP
Wait out a deadline.
@ SRN_REACTOR_IO_NOP
Completes immediately with a zero result.
static srn_reactor_io_completion_t reactor_test_await(srn_reactor_t *r, size_t channel)
static void reactor_test_start(srn_reactor_t *r, size_t nworkers)
static void test_reactor_lifecycle()
static void test_reactor_channel_routing()
static void test_reactor_sleep()
static void test_reactor_activate_shutdown()
static void test_reactor_fresh_state()
static void test_reactor_nop_roundtrip()
static void test_reactor_cq_spsc_stress()
static void reactor_test_submit(srn_reactor_t *r, size_t channel, const srn_reactor_io_request_t *req)
void srn_sched_wake_worker(srn_scheduler_t *sched, size_t channel)
Rouse parked workers so the owner of channel consumes its completions.
bool srn_spsc_ring_push(srn_spsc_ring_t *r, const void *elem)
Producer side.
A mutable single producer, single consumer ring of fixed size elements.
void(* wake)(srn_reactor_t *reactor)
A completion, the result of one submission, echoed back on the channel.
void * fiber_data
The fiber_data of the submission this completes.
size_t result
The result of the operation on success, bytes transferred for the transfers, the accepted descriptor ...
A submission, one request a fiber places on its channel.
srn_reactor_io_channel_t * channels
One channel per worker, there is a 1to1 mapping between worker ids and channel ids.
const srn_reactor_backend_t * backend
The chosen kernel mechanism and its private state, set at activation.
#define SRN_NS_PER_MS
nanoseconds in one millisecond
uint64_t srn_now_ns(void)
The current time on the monotonic clock, in nanoseconds.