Flow-IPC 3.0.0
Flow-IPC project: Full implementation reference.
transport_fwd.hpp
Go to the documentation of this file.
1/* Flow-IPC: Core
2 * Copyright 2023 Akamai Technologies, Inc.
3 *
4 * Licensed under the Apache License, Version 2.0 (the
5 * "License"); you may not use this file except in
6 * compliance with the License. You may obtain a copy
7 * of the License at
8 *
9 * https://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in
12 * writing, software distributed under the License is
13 * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
14 * CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing
16 * permissions and limitations under the License. */
17
18/// @file
19#pragma once
20
22#include <iosfwd>
23
24namespace ipc::transport
25{
26
27// Types.
28
29// Find doc headers near the bodies of these compound types.
30
31template<typename Base_t>
32struct Native_socket_stream_msg_batch_in_privileged;
33class Native_socket_stream_impl;
34template<typename Persistent_mq_handle>
35class Blob_stream_mq_base_impl;
36template<typename Persistent_mq_handle>
37class Blob_stream_mq_receiver_impl;
38template<typename Persistent_mq_handle>
39class Blob_stream_mq_sender_impl;
40
41// Free functions.
42
43/**
44 * Prints string representation of the given Native_socket_stream_impl to the given `ostream`.
45 *
46 * @relatesalso Native_socket_stream_impl
47 *
48 * @param os
49 * Stream to which to write.
50 * @param val
51 * Object to serialize.
52 * @return `os`.
53 */
54std::ostream& operator<<(std::ostream& os, const Native_socket_stream_impl& val);
55
56/**
57 * Prints string representation of the given `Blob_stream_mq_receiver_impl` to the given `ostream`.
58 *
59 * @relatesalso Blob_stream_mq_receiver_impl
60 *
61 * @param os
62 * Stream to which to write.
63 * @param val
64 * Object to serialize.
65 * @return `os`.
66 */
67template<typename Persistent_mq_handle>
68std::ostream& operator<<(std::ostream& os, const Blob_stream_mq_receiver_impl<Persistent_mq_handle>& val);
69
70/**
71 * Prints string representation of the given `Blob_stream_mq_sender` to the given `ostream`.
72 *
73 * @relatesalso Blob_stream_mq_sender_impl
74 *
75 * @param os
76 * Stream to which to write.
77 * @param val
78 * Object to serialize.
79 * @return `os`.
80 */
81template<typename Persistent_mq_handle>
82std::ostream& operator<<(std::ostream& os, const Blob_stream_mq_sender_impl<Persistent_mq_handle>& val);
83
84} // namespace ipc::transport
85
87{
88
89// Types.
90
91// Find doc headers near the bodies of these compound types.
92
94template<typename Core_t>
96template<typename Core_t>
98template<typename Persistent_mq_handle>
100template<typename Persistent_mq_handle>
102
103// Free functions.
104
105/**
106 * Helper for async_receive_batch_emulation() that executes on that call's *initial* single-message async-read
107 * (whether the result was immediate or following an async-wait due to initial would-block). In short, then,
108 * - If `init_err_code`, it saves it to `*sync_err_code` and returns. Otherwise:
109 * - It performs further single-message sync-reads, stopping once any of the following occurs (but in all cases
110 * setting `*sync_err_code` to success (falsy)):
111 * - `batch->full()` (might be the case at entry already);
112 * - would-block;
113 * - error. (The error is not emitted, as the pre-condition at this stage is 1+ in-messages have already been
114 * received, and async-receive overall must not emit both messages and error, nor just the latter while eating
115 * the fotmer! Hence `async_rcv_impl_func()` should cache it, if it is pipe-hosing,
116 * so the next async-receive immediately emits it.)
117 *
118 * @param logger_ptr
119 * See async_receive_batch_emulation().
120 * @param batch
121 * See async_receive_batch_emulation().
122 * @param sync_err_code
123 * See async_receive_batch_emulation().
124 * @param async_rcv_impl_func
125 * See async_receive_batch_emulation().
126 * @param init_err_code
127 * The result of the initial `async_rcv_impl_func()` call in this async_receive_batch_emulation().
128 * @param init_sz
129 * If `init_err_code` is success: The # of bytes received by the initial `async_rcv_impl_func()` call in this
130 * async_receive_batch_emulation().
131 */
132template<bool NO_HNDLS, typename Batch, typename Async_rcv_impl_func>
133void async_receive_batch_emulation_on_init_msg(flow::log::Logger* logger_ptr,
134 Batch* batch, Error_code* sync_err_code,
135 const Async_rcv_impl_func& async_rcv_impl_func,
136 const Error_code init_err_code, size_t init_sz);
137
138/**
139 * Prints string representation of the given Native_socket_stream_impl to the given `ostream`.
140 *
141 * @relatesalso Native_socket_stream_impl
142 *
143 * @param os
144 * Stream to which to write.
145 * @param val
146 * Object to serialize.
147 * @return `os`.
148 */
149std::ostream& operator<<(std::ostream& os, const Native_socket_stream_impl& val);
150
151/**
152 * Prints string representation of the given `Blob_stream_mq_receiver_impl` to the given `ostream`.
153 *
154 * @relatesalso Blob_stream_mq_receiver_impl
155 *
156 * @param os
157 * Stream to which to write.
158 * @param val
159 * Object to serialize.
160 * @return `os`.
161 */
162template<typename Persistent_mq_handle>
163std::ostream& operator<<(std::ostream& os, const Blob_stream_mq_receiver_impl<Persistent_mq_handle>& val);
164
165/**
166 * Prints string representation of the given `Blob_stream_mq_sender` to the given `ostream`.
167 *
168 * @relatesalso Blob_stream_mq_sender_impl
169 *
170 * @param os
171 * Stream to which to write.
172 * @param val
173 * Object to serialize.
174 * @return `os`.
175 */
176template<typename Persistent_mq_handle>
177std::ostream& operator<<(std::ostream& os, const Blob_stream_mq_sender_impl<Persistent_mq_handle>& val);
178
179} // namespace ipc::transport::sync_io
Type that adapts a given PEER-state sync_io::Native_handle_receiver or sync_io::Blob_receiver core in...
Type that adapts a given PEER-state sync_io::Native_handle_sender or sync_io::Blob_sender core into t...
Internal, non-movable pImpl-lite implementation of sync_io::Blob_stream_mq_receiver class template.
Internal, non-movable pImpl-lite implementation of sync_io::Blob_stream_mq_sender class template.
Internal, non-movable pImpl-lite implementation of sync_io::Native_socket_stream class.
sync_io-pattern counterparts to async-I/O-pattern object types in parent namespace ipc::transport.
std::ostream & operator<<(std::ostream &os, const Native_socket_stream_impl &val)
Prints string representation of the given Native_socket_stream_impl to the given ostream.
void async_receive_batch_emulation_on_init_msg(flow::log::Logger *logger_ptr, Batch *batch, Error_code *sync_err_code, const Async_rcv_impl_func &async_rcv_impl_func, const Error_code init_err_code, size_t init_sz)
Helper for async_receive_batch_emulation() that executes on that call's initial single-message async-...
Definition: batch.hpp:31
Flow-IPC module providing transmission of structured messages and/or low-level blobs (and more) betwe...
std::ostream & operator<<(std::ostream &os, const Generic_msg_batch_in< Msg_resource_t, NO_HNDLS > &val)
Prints string representation of the given Generic_msg_batch_in to the given ostream.
Definition: batch.hpp:431
flow::Error_code Error_code
Short-hand for flow::Error_code which is very common.
Definition: common.hpp:313