5#include <bio/mailbox.h>
84#define BIO_SERVICE(T) \
87 BIO_MAILBOX(T) mailbox; \
91#define BIO_SERVICE_MSG bio_service_msg_base_t bio__service_msg_base;
102#define bio_start_service(ptr, entry, args) \
103 bio_start_service_ex(ptr, entry, args, NULL)
120#define bio_start_service_ex(ptr, entry, args, options) \
123 &(ptr)->mailbox.bio__handle, \
124 sizeof(*((ptr)->mailbox.bio__message)), \
141#define bio_stop_service(service) \
142 bio__service_stop((service).coro, (service).mailbox.bio__handle)
152#define bio_get_service_info(userdata, mailbox_ptr, args_ptr) \
153 bio__service_get_info(userdata, &(mailbox_ptr)->bio__handle, args_ptr)
180#define bio_call_service(service, message, cancel_signal) \
182 BIO__TYPECHECK_EXP((message), *((service).mailbox.bio__message)), \
185 (service).mailbox.bio__handle, \
186 &((message).bio__service_msg_base), \
199#define bio_service_state(service) \
200 bio_coro_state((service).coro)
215#define bio_notify_service(service, message, retry_condition) \
216 bio_wait_and_send_message( \
217 ((bio_service_state(service) != BIO_CORO_DEAD) && (retry_condition)), \
235#define bio_is_call_cancelled(msg) \
236 bio__service_is_call_cancelled(&(msg).bio__service_msg_base)
249#define bio_service_loop(msg, mailbox) \
250 bio_foreach_message(msg, mailbox) \
252 int bio__svc_loop = 0; \
253 (bio__svc_loop < 1) && !bio_is_call_cancelled(msg); \
316#define bio_respond(msg) \
318 bool bio__should_respond = bio_begin_response(msg); \
319 bio__should_respond; \
320 bio__should_respond = false, bio_end_response(msg) \
325#define bio_begin_response(msg) \
326 (bio__service_begin_response(&(msg).bio__service_msg_base))
328#define bio_end_response(msg) \
329 bio_raise_signal((msg).bio__service_msg_base.bio__ack_signal)
335 size_t mailbox_msg_size,
343bio__service_get_info(
void* userdata,
bio_handle_t* mailbox_ptr,
void* args);
void(* bio_entrypoint_t)(void *userdata)
Entrypoint for a coroutine.
Definition bio.h:120
bio_call_status_t
The status of a call using bio_call_service.
Definition service.h:39
@ BIO_CALL_TARGET_DEAD
The service has terminated during or before the call.
Definition service.h:45
@ BIO_CALL_CANCELLED
The call was cancelled by the caller.
Definition service.h:43
@ BIO_CALL_OK
The call was handled by the service.
Definition service.h:41
Coroutine spawn options.
Definition bio.h:535
Handle to a coroutine.
Definition bio.h:137
The base for a message type of a service.
Definition service.h:54
Options for service.
Definition service.h:64
uint32_t mailbox_capacity
Capacity of the service's mailbox.
Definition service.h:76
bio_coro_options_t coro_options
Coroutine options.
Definition service.h:70
Handle to a signal.
Definition bio.h:147