23#include <flow/log/log.hpp>
32template<
bool NO_HNDLS,
typename Batch,
typename Task_err,
typename Async_rcv_impl_func>
34 Batch* batch,
bool assume_would_block,
Error_code* sync_err_code,
35 Task_err&& on_done_func,
36 Async_rcv_impl_func&& async_rcv_impl_func)
38 assert(sync_err_code);
88 FLOW_LOG_SET_CONTEXT(logger_ptr, Log_component::S_TRANSPORT);
90 if (!batch->initialized())
92 FLOW_LOG_WARNING(
"Msg_batch [" << *batch <<
"]: Emulating async-receive (no-hndls? = [" << NO_HNDLS <<
"]; "
93 "assume-would-block? = [" << assume_would_block <<
"]): "
94 "By contract emitting invalid-argument error, because the user- or library-supplied "
95 "batch object is not initialized() (not all slots have been prepare_target_payload()ed).");
107 FLOW_LOG_TRACE(
"Msg_batch [" << *batch <<
"]: Emulating async-receive (no-hndls? = [" << NO_HNDLS <<
"]; "
108 "assume-would-block? = [" << assume_would_block <<
"]).");
110 size_t sync_init_sz = 0;
111 if constexpr(NO_HNDLS)
113 async_rcv_impl_func(assume_would_block, batch->next_target_blob(), sync_err_code, &sync_init_sz,
114 [logger_ptr, batch, on_done_func = std::move(on_done_func),
116 (
const Error_code& init_err_code,
size_t init_sz)
mutable
121 async_receive_batch_emulation_on_init_msg<NO_HNDLS>
122 (logger_ptr, batch, &err_code, async_rcv_impl_func, init_err_code, init_sz);
124 on_done_func(err_code);
129 async_rcv_impl_func(batch->next_target_hndl(), assume_would_block, batch->next_target_blob(),
130 sync_err_code, &sync_init_sz,
131 [logger_ptr, batch, on_done_func = std::move(on_done_func), async_rcv_impl_func]
132 (
const Error_code& init_err_code,
size_t init_sz)
mutable
135 async_receive_batch_emulation_on_init_msg<NO_HNDLS>
136 (logger_ptr, batch, &err_code, async_rcv_impl_func, init_err_code, init_sz);
137 on_done_func(err_code);
148 async_receive_batch_emulation_on_init_msg<NO_HNDLS>
149 (logger_ptr, batch, sync_err_code, async_rcv_impl_func, *sync_err_code, sync_init_sz);
@ S_SYNC_IO_WOULD_BLOCK
A sync_io operation could not immediately complete; it will complete contingent on active async-wait ...
@ S_INVALID_ARGUMENT
User called an API with 1 or more arguments against the API spec.
sync_io-pattern counterparts to async-I/O-pattern object types in parent namespace ipc::transport.
void async_receive_batch_emulation(flow::log::Logger *logger_ptr, Batch *batch, bool assume_would_block, Error_code *sync_err_code, Task_err &&on_done_func, Async_rcv_impl_func &&async_rcv_impl_func)
Implements {Native_handle|Blob}_receiver::async_receive_*_batch() by emulating batch-receiving as a s...
flow::Error_code Error_code
Short-hand for flow::Error_code which is very common.