From a5061fa634af1e7011182e1c115151dd96af8393 Mon Sep 17 00:00:00 2001 From: "Luke T. Shumaker" Date: Wed, 16 Apr 2025 05:21:31 -0600 Subject: lib9p_srv: Re-think flush semantics --- libcr_ipc/include/libcr_ipc/chan.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'libcr_ipc/include') diff --git a/libcr_ipc/include/libcr_ipc/chan.h b/libcr_ipc/include/libcr_ipc/chan.h index 79be220..853b4ad 100644 --- a/libcr_ipc/include/libcr_ipc/chan.h +++ b/libcr_ipc/include/libcr_ipc/chan.h @@ -97,9 +97,25 @@ (CH)->core.waiters.front->val.op == _CR_SELECT_OP_SEND); \ }) +/** + * cr_chan_num_waiters(ch) returns the number of coroutines currently + * blocked on the channel. + * + * @runs_in coroutine + * @cr_pauses never + * @cr_yields never + * + * size_t cr_chan_num_waiters(NAME##_t *ch); + */ +#define cr_chan_num_waiters(CH) ({ \ + cr_assert_in_coroutine(); \ + ((CH)->core.nwaiters); \ +}) + DLIST_DECLARE(_cr_select_arg_list); struct _cr_chan { struct _cr_select_arg_list waiters; + size_t nwaiters; }; /* cr_select arguments ********************************************************/ -- cgit v1.2.3-2-g168b