72template<
typename Session_server>
99 template<
typename... Ctor_args>
113 template<
typename Event_wait_func_t>
114 bool start_ops(Event_wait_func_t&& ev_wait_func);
125 template<
typename Create_ev_wait_hndl_func>
144 template<
typename Task_err>
174 template<
typename Task_err,
175 typename N_init_channels_by_srv_req_func,
typename Mdt_load_func>
180 N_init_channels_by_srv_req_func&& n_init_channels_by_srv_req_func,
181 Mdt_load_func&& mdt_load_func,
182 Task_err&& on_done_func);
264template<
typename Session_server>
265template<
typename... Ctor_args>
267 m_ready_reader(m_nb_task_engine),
268 m_ready_writer(m_nb_task_engine),
269 m_ev_wait_hndl(m_ev_hndl_task_engine_unused),
270 m_async_io(std::forward<Ctor_args>(ctor_args)...)
273 using boost::asio::connect_pipe;
280 FLOW_LOG_FATAL(
"Session_server_adapter [" << *
this <<
"]: Constructing: connect-pipe failed. Details follow.");
281 FLOW_ERROR_SYS_ERROR_LOG_FATAL();
282 assert(
false &&
"We chose not to complicate the code given how unlikely this is, and how hosed you'd have to be.");
289template<
typename Session_server>
290template<
typename Event_wait_func_t>
295 if (!m_ev_wait_func.empty())
297 FLOW_LOG_WARNING(
"Session_server_adapter [" << *
this <<
"]: Start-ops requested, "
298 "but we are already started. Probably a user bug, but it is not for us to judge.");
303 m_ev_wait_func = std::move(ev_wait_func);
305 FLOW_LOG_INFO(
"Session_server_adapter [" << *
this <<
"]: Start-ops requested. Done.");
311template<
typename Session_server>
312template<
typename Create_ev_wait_hndl_func>
314 (
const Create_ev_wait_hndl_func& create_ev_wait_hndl_func)
318 if (!m_ev_wait_func.empty())
320 FLOW_LOG_WARNING(
"Session_server_adapter [" << *
this <<
"]: Cannot replace event-wait handles after "
321 "a start-*-ops procedure has been executed. Ignoring.");
326 FLOW_LOG_INFO(
"Session_server_adapter [" << *
this <<
"]: "
327 "Replacing event-wait handles (probably to replace underlying "
328 "execution context without outside event loop's boost.asio Task_engine or similar).");
330 assert(m_ev_wait_hndl.is_open());
333 m_ev_wait_hndl = create_ev_wait_hndl_func();
334 m_ev_wait_hndl.assign(saved);
339template<
typename Session_server>
340template<
typename Task_err>
345 if (!m_on_done_func_or_empty.empty())
347 FLOW_LOG_WARNING(
"Session_server_adapter [" << *
this <<
"]: "
348 "Async-accept requested during async-accept. Ignoring.");
352 m_on_done_func_or_empty = std::move(on_done_func);
354 core()->async_accept(target_session->
core(),
355 [
this](
const Error_code& err_code) { accept_write(err_code); });
358 m_ev_wait_func(&m_ev_wait_hndl,
360 boost::make_shared<Task>([
this]() { accept_read(); }));
365template<
typename Session_server>
366template<
typename Task_err,
367 typename N_init_channels_by_srv_req_func,
typename Mdt_load_func>
373 N_init_channels_by_srv_req_func&& n_init_channels_by_srv_req_func,
374 Mdt_load_func&& mdt_load_func,
375 Task_err&& on_done_func)
379 if (!m_on_done_func_or_empty.empty())
381 FLOW_LOG_WARNING(
"Session_server_adapter [" << *
this <<
"]: "
382 "Async-accept requested during async-accept. Ignoring.");
386 m_on_done_func_or_empty = std::move(on_done_func);
388 core()->async_accept(target_session->
core(),
389 init_channels_by_srv_req, mdt_from_cli_or_null, init_channels_by_cli_req,
390 std::move(n_init_channels_by_srv_req_func), std::move(mdt_load_func),
391 [
this](
const Error_code& err_code) { accept_write(err_code); });
394 m_ev_wait_func(&m_ev_wait_hndl,
396 boost::make_shared<Task>([
this]() { accept_read(); }));
401template<
typename Session_server>
410 FLOW_LOG_INFO(
"Session_server_adapter [" << *
this <<
"]: Async-IO core reports accept-complete event: "
411 "tickling IPC-pipe to inform user.");
413 m_target_err_code = err_code;
418template<
typename Session_server>
421 FLOW_LOG_INFO(
"Session_server_adapter [" << *
this <<
"]: Async-IO core accept-complete event: "
422 "informed via IPC-pipe; invoking handler.");
425 auto on_done_func = std::move(m_on_done_func_or_empty);
426 m_on_done_func_or_empty.clear();
428 on_done_func(m_target_err_code);
429 FLOW_LOG_TRACE(
"Handler completed.");
432template<
typename Session_server>
439template<
typename Session_server>
446template<
typename Session_server>
449 return core()->get_logger();
452template<
typename Session_server>
455 return core()->get_log_component();
458template<
typename Session_server>
462 return os <<
"SIO@" <<
static_cast<const void*
>(&val) <<
" sess_srv[" << (*(val.
core())) <<
']';
To be instantiated typically once in a given process, an object of this type asynchronously listens f...
typename Impl::Channels Channels
Short-hand for Session_mv::Channels.
typename Impl::Mdt_reader_ptr Mdt_reader_ptr
Short-hand for Session_mv::Mdt_reader_ptr.
sync_io-pattern counterpart to async-I/O-pattern session::Server_session types and all their SHM-awar...
Session_obj * core()
The adapted mutable Session_obj.
sync_io-pattern counterpart to async-I/O-pattern session::Session_server types and all their SHM-awar...
util::sync_io::Event_wait_func m_ev_wait_func
Similar to the one in Session_adapter.
Session_server_adapter(Ctor_args &&... ctor_args)
Forwards to the Session_server_obj ctor.
util::Pipe_writer m_ready_writer
Similar to the one in Session_adapter, applied to async_accept().
void accept_read()
Signaled by accept_write(), it returns the IPC-pipe to steady-state (empty, not readable),...
bool async_accept(Session_obj *target_session, Task_err &&on_done_func)
Acts identically to 1-arg overload of Session_server::async_accept(), except that the completion hand...
util::sync_io::Asio_waitable_native_handle m_ev_wait_hndl
Similar to the one in Session_adapter, applied to async_accept().
util::Pipe_reader m_ready_reader
Similar to the one in Session_adapter, applied to async_accept().
Error_code m_target_err_code
Result given to (or about to be given to) m_on_done_func_or_empty.
flow::util::Task_engine m_nb_task_engine
Similar to the one in Session_adapter.
Session_server_obj * core()
The adapted mutable Session_server_obj.
flow::util::Task_engine m_ev_hndl_task_engine_unused
Similar to the one in Session_adapter.
const flow::log::Component & get_log_component() const
See flow::log::Log_context.
bool start_ops(Event_wait_func_t &&ev_wait_func)
All notes from Client_session_adapter::start_ops() apply equally.
void accept_write(const Error_code &err_code)
The real handler given for on_done_func to Session_server_obj::async_accept(): it records the result ...
flow::async::Task_asio_err m_on_done_func_or_empty
on_done_func from async_accept() if one is pending; otherwise .empty().
Async_io_obj m_async_io
This guy does all the work. In our dtor this will be destroyed (hence thread stopped) first-thing.
flow::log::Logger * get_logger() const
See flow::log::Log_context.
bool replace_event_wait_handles(const Create_ev_wait_hndl_func &create_ev_wait_hndl_func)
All notes from Client_session_adapter::replace_event_wait_handles() apply equally.
Session_server Session_server_obj
Short-hand, for generic programming et al, for template parameter Session_server.
Dummy type for use as a template param to Channel when either the blobs pipe or handles pipe is disab...
Useful if using the sync_io pattern within a user event loop built on boost.asio (optionally with flo...
void assign(Native_handle hndl)
Loads value to be returned by native_handle().
@ S_OBJECT_SHUTDOWN_ABORTED_COMPLETION_HANDLER
Async completion handler is being called prematurely, because underlying object is shutting down,...
sync_io-pattern counterparts to async-I/O-pattern object types in parent namespace ipc::session.
std::ostream & operator<<(std::ostream &os, const Server_session_adapter< Session > &val)
Prints string representation of the given Server_session_adapter to the given ostream.
util::Native_handle Native_handle
Convenience alias for the commonly used type util::Native_handle.
Function< void(Asio_waitable_native_handle *hndl_of_interest, bool ev_of_interest_snd_else_rcv, Task_ptr &&on_active_ev_func)> Event_wait_func
In sync_io pattern, concrete type storing user-supplied function invoked by pattern-implementing ipc:...
flow::async::Task Task
Short-hand for polymorphic function (a-la std::function<>) that takes no arguments and returns nothin...
void pipe_produce(flow::log::Logger *logger_ptr, Pipe_writer *pipe)
Writes a byte to the given pipe writer.
void pipe_consume(flow::log::Logger *logger_ptr, Pipe_reader *pipe)
Reads a byte via the given pipe reader.
boost::asio::writable_pipe Pipe_writer
Short-hand for anonymous pipe write end.
boost::asio::readable_pipe Pipe_reader
Short-hand for anonymous pipe read end.
flow::Error_code Error_code
Short-hand for flow::Error_code which is very common.
A monolayer-thin wrapper around a native handle, a/k/a descriptor a/k/a FD.