Flow-IPC 3.0.0
Flow-IPC project: Full implementation reference.
bipc_mq_handle.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 "ipc/util/util_fwd.hpp"
25#include <flow/log/log.hpp>
26#include <boost/move/unique_ptr.hpp>
27
28namespace ipc::transport
29{
30
31// Types.
32
33/**
34 * Implements the Persistent_mq_handle concept by thinly wrapping `bipc::message_queue`, which is boost.interprocess's
35 * persistent message queue API. Internally `bipc::message_queue` maintains a boost.interprocess (classic)
36 * SHM pool which itself is a portable wrapper around a standard POSIX shared memory object.
37 *
38 * @see Persistent_mq_handle: implemented concept. Its doc header provides plenty of background for the present
39 * concrete class, since essentially that concept was inspired by `bipc::message_queue` in the first place.
40 * Therefore there is essentially no added documentation needed here.
41 *
42 * Reminder: This is available publicly in case it is useful; but it is more likely one would use a Blob_stream
43 * which provides a far more convenient boost.asio-like async-capable API. It uses class(es) like this one in
44 * its impl.
45 *
46 * @internal
47 * ### Implementation ###
48 * It is really a thin wrapper around `bipc::message_queue` as discussed above/in Persistent_mq_handle doc header.
49 * To the extent it adds its own intelligence, it's only about normalizing error reporting and adding logging.
50 */
51class Bipc_mq_handle : // Note: movable but not copyable.
52 public flow::log::Log_context
53{
54public:
55 // Constants.
56
57 /// Implements concept API.
59
60 /// Implements concept API.
61 static constexpr bool S_HAS_NATIVE_HANDLE = false;
62
63 // Constructors/destructor.
64
65 /// Implements Persistent_mq_handle API: Construct null handle.
67
68 /**
69 * Implements Persistent_mq_handle API: Construct handle to non-existing named MQ, creating it first. If it already
70 * exists, it is an error.
71 *
72 * @param logger_ptr
73 * See above.
74 * @param absolute_name
75 * See above.
76 * @param mode_tag
77 * See above.
78 * @param perms
79 * See above.
80 * Reminder: Suggest the use of util::shared_resource_permissions() to translate
81 * from one of a small handful of levels of access; these apply almost always in practice.
82 * @param max_n_msg
83 * See above.
84 * @param max_msg_sz
85 * See above.
86 * @param err_code
87 * See above.
88 */
89 explicit Bipc_mq_handle(flow::log::Logger* logger_ptr, const Shared_name& absolute_name,
90 util::Create_only mode_tag, size_t max_n_msg, size_t max_msg_sz,
91 const util::Permissions& perms = {}, Error_code* err_code = nullptr);
92 /**
93 * Implements Persistent_mq_handle API: Construct handle to existing named MQ, or else if it does not exist creates
94 * it first and opens it (atomically).
95 *
96 * @param logger_ptr
97 * See above.
98 * @param absolute_name
99 * See above.
100 * @param mode_tag
101 * See above.
102 * @param perms_on_create
103 * See above.
104 * Reminder: Suggest the use of util::shared_resource_permissions() to translate
105 * from one of a small handful of levels of access; these apply almost always in practice.
106 * @param max_n_msg_on_create
107 * See above.
108 * @param max_msg_sz_on_create
109 * See above.
110 * @param err_code
111 * See above.
112 */
113 explicit Bipc_mq_handle(flow::log::Logger* logger_ptr, const Shared_name& absolute_name,
114 util::Open_or_create mode_tag, size_t max_n_msg_on_create, size_t max_msg_sz_on_create,
115 const util::Permissions& perms_on_create = {}, Error_code* err_code = nullptr);
116 /**
117 * Implements Persistent_mq_handle API: Construct handle to existing named MQ. If it does not exist, it is an error.
118 *
119 * @param logger_ptr
120 * See above.
121 * @param absolute_name
122 * See above.
123 * @param mode_tag
124 * See above.
125 * @param err_code
126 * See above.
127 */
128 explicit Bipc_mq_handle(flow::log::Logger* logger_ptr, const Shared_name& absolute_name,
129 util::Open_only mode_tag, Error_code* err_code = nullptr);
130
131 /**
132 * Implements Persistent_mq_handle API: Constructs handle from the source handle while making the latter as-if
133 * default-cted. Reminder, informally: This is a light-weight op.
134 *
135 * @param src
136 * See above.
137 */
139
140 /// Copying of handles is prohibited, per Persistent_mq_handle concept.
142
143 /**
144 * Implements Persistent_mq_handle API: Destroys this handle (or no-op if no handle was successfully constructed, or
145 * if it's a moved-from or default-cted handle). Reminder: The underlying MQ (if any) is *not* destroyed and can
146 * be attached-to by another handle.
147 */
149
150 // Methods.
151
152 /**
153 * Implements Persistent_mq_handle API: Replaces handle with the source handle while making the latter invalid as-if
154 * default-cted. Reminder, informally: this is a light-weight op.
155 *
156 * @param src
157 * See above.
158 * @return `*this`.
159 */
161
162 /// Copying of handles is prohibited, per Persistent_mq_handle concept.
164
165 /**
166 * Implements Persistent_mq_handle API: Removes the named persistent MQ. Reminder: name is removed immediately
167 * (if present -- otherwise error), but underlying MQ continues to exist until all system-wide handles to it
168 * are closed.
169 *
170 * @see Reminder: see also `util::remove_each_persistent_*()`.
171 *
172 * @param logger_ptr
173 * See above.
174 * @param absolute_name
175 * See above.
176 * @param err_code
177 * See above.
178 */
179 static void remove_persistent(flow::log::Logger* logger_ptr, const Shared_name& absolute_name,
180 Error_code* err_code = nullptr);
181
182 /**
183 * Implements Persistent_mq_handle API. Impl note for exposition: we use the fact that bipc stores each MQ
184 * in a same-named SHM pool; those are listed in flat fashion (e.g., in Linux in `/dev/shm`).
185 *
186 * @tparam Handle_name_func
187 * See above.
188 * @param handle_name_func
189 * See above.
190 */
191 template<typename Handle_name_func>
192 static void for_each_persistent(const Handle_name_func& handle_name_func);
193
194 /**
195 * Implements Persistent_mq_handle API: Non-blocking send: pushes copy of message to queue and returns `true`;
196 * if queue is full then no-op and returns `false`.
197 *
198 * ### INFO+ logging ###
199 * WARNING on error. (You may use the `flow::log::Config::this_thread_verbosity_override_auto()` to
200 * temporarily, in that thread only, disable/reduce logging. This is quite easy and performant.)
201 *
202 * @param blob
203 * See above.
204 * @param err_code
205 * See above.
206 * @return See above.
207 */
208 bool try_send(const util::Blob_const& blob, Error_code* err_code = nullptr);
209
210 /**
211 * Implements Persistent_mq_handle API: Blocking send: pushes copy of message to queue; if queue is full blocks
212 * until it is not.
213 *
214 * ### INFO+ logging ###
215 * WARNING on error. (You may use the `flow::log::Config::this_thread_verbosity_override_auto()`
216 * to temporarily, in that thread only, disable/reduce logging. This is quite easy and performant.)
217 *
218 * @param blob
219 * See above.
220 * @param err_code
221 * See above.
222 */
223 void send(const util::Blob_const& blob, Error_code* err_code = nullptr);
224
225 /**
226 * Implements Persistent_mq_handle API: Blocking timed send: pushes copy of message to queue; if queue is full
227 * blocks until it is not, or the specified time passes, whichever happens first.
228 *
229 * ### INFO+ logging ###
230 * WARNING on error. (You may use the `flow::log::Config::this_thread_verbosity_override_auto()` to
231 * temporarily, in that thread only, disable/reduce logging. This is quite easy and performant.)
232 *
233 * @param blob
234 * See above.
235 * @param timeout_from_now
236 * See above.
237 * @param err_code
238 * See above.
239 * @return See above.
240 */
241 bool timed_send(const util::Blob_const& blob, util::Fine_duration timeout_from_now, Error_code* err_code = nullptr);
242
243 /**
244 * Implements Persistent_mq_handle API: Like try_send() but without the actual pushing of a message.
245 *
246 * ### INFO+ logging ###
247 * WARNING on error. (You may use the `flow::log::Config::this_thread_verbosity_override_auto()` to
248 * temporarily, in that thread only, disable/reduce logging. This is quite easy and performant.)
249 *
250 * @param err_code
251 * See above.
252 * @return See above.
253 */
254 bool is_sendable(Error_code* err_code = nullptr);
255
256 /**
257 * Implements Persistent_mq_handle API: Like send() but without the actual pushing of a message.
258 *
259 * ### INFO+ logging ###
260 * WARNING on error. (You may use the `flow::log::Config::this_thread_verbosity_override_auto()` to
261 * temporarily, in that thread only, disable/reduce logging. This is quite easy and performant.)
262 *
263 * @param err_code
264 * See above.
265 */
266 void wait_sendable(Error_code* err_code = nullptr);
267
268 /**
269 * Implements Persistent_mq_handle API: Like timed_send() but without the actual pushing of a message.
270 *
271 * ### INFO+ logging ###
272 * WARNING on error. (You may use the `flow::log::Config::this_thread_verbosity_override_auto()` to
273 * temporarily, in that thread only, disable/reduce logging. This is quite easy and performant.)
274 *
275 * @param timeout_from_now
276 * See above.
277 * @param err_code
278 * See above.
279 * @return See above.
280 */
281 bool timed_wait_sendable(util::Fine_duration timeout_from_now, Error_code* err_code = nullptr);
282
283 /**
284 * Implements Persistent_mq_handle API: Non-blocking receive: pops copy of message from queue into buffer and
285 * returns `true`; if queue is empty then no-op and returns `false`.
286 *
287 * ### INFO+ logging ###
288 * WARNING on error. (You may use the `flow::log::Config::this_thread_verbosity_override_auto()` to
289 * temporarily, in that thread only, disable/reduce logging. This is quite easy and performant.)
290 *
291 * @param blob
292 * See above.
293 * @param err_code
294 * See above.
295 * @return See above.
296 */
297 bool try_receive(util::Blob_mutable* blob, Error_code* err_code = nullptr);
298
299 /**
300 * Implements Persistent_mq_handle API: Blocking receive: pops copy of message from queue into buffer; if queue
301 * is empty blocks until it is not.
302 *
303 * ### INFO+ logging ###
304 * WARNING on error. (You may use the `flow::log::Config::this_thread_verbosity_override_auto()` to
305 * temporarily, in that thread only, disable/reduce logging. This is quite easy and performant.)
306 *
307 * @param blob
308 * See above.
309 * @param err_code
310 * See above.
311 */
312 void receive(util::Blob_mutable* blob, Error_code* err_code = nullptr);
313
314 /**
315 * Implements Persistent_mq_handle API: Blocking timed receive: pops copy of message from queue into buffer;
316 * if queue is empty blocks until it is not, or the specified time passes, whichever happens first.
317 *
318 * ### INFO+ logging ###
319 * WARNING on error or timed out.
320 * (You may use the `flow::log::Config::this_thread_verbosity_override_auto()` to
321 * temporarily, in that thread only, disable/reduce logging. This is quite easy and performant.)
322 *
323 * @param blob
324 * See above.
325 * @param timeout_from_now
326 * See above.
327 * @param err_code
328 * See above.
329 * @return See above.
330 */
331 bool timed_receive(util::Blob_mutable* blob, util::Fine_duration timeout_from_now, Error_code* err_code = nullptr);
332
333 /**
334 * Implements Persistent_mq_handle API: Like try_receive() but without the actual popping of a message.
335 *
336 * ### INFO+ logging ###
337 * WARNING on error. (You may use the `flow::log::Config::this_thread_verbosity_override_auto()` to
338 * temporarily, in that thread only, disable/reduce logging. This is quite easy and performant.)
339 *
340 * @param err_code
341 * See above.
342 * @return See above.
343 */
344 bool is_receivable(Error_code* err_code = nullptr);
345
346 /**
347 * Implements Persistent_mq_handle API: Like receive() but without the actual popping of a message.
348 *
349 * ### INFO+ logging ###
350 * WARNING on error. (You may use the `flow::log::Config::this_thread_verbosity_override_auto()` to
351 * temporarily, in that thread only, disable/reduce logging. This is quite easy and performant.)
352 *
353 * @param err_code
354 * See above.
355 */
356 void wait_receivable(Error_code* err_code = nullptr);
357
358 /**
359 * Implements Persistent_mq_handle API: Like timed_receive() but without the actual popping of a message.
360 *
361 * ### INFO+ logging ###
362 * WARNING on error or timed out. (You may use the `flow::log::Config::this_thread_verbosity_override_auto()` to
363 * temporarily, in that thread only, disable/reduce logging. This is quite easy and performant.)
364 *
365 * @param timeout_from_now
366 * See above.
367 * @param err_code
368 * See above.
369 * @return See above.
370 */
371 bool timed_wait_receivable(util::Fine_duration timeout_from_now, Error_code* err_code = nullptr);
372
373 /**
374 * Implements Persistent_mq_handle API:
375 * Turn on preemptive/concurrent interruption of blocking-sends and sendable-waits/polls.
376 *
377 * ### INFO+ logging ###
378 * WARNING on duplicate use, INFO otherwise.
379 *
380 * @return See above.
381 */
382 bool interrupt_sends();
383
384 /**
385 * Implements Persistent_mq_handle API:
386 * Turn off preemptive/concurrent interruption of blocking-sends and sendable-waits/polls.
387 *
388 * ### INFO+ logging ###
389 * WARNING on duplicate use, INFO otherwise.
390 *
391 * @return See above.
392 */
393 bool allow_sends();
394
395 /**
396 * Implements Persistent_mq_handle API:
397 * Turn on preemptive/concurrent interruption of blocking-receives and receivable-waits/polls.
398 *
399 * ### INFO+ logging ###
400 * WARNING on duplicate use, INFO otherwise.
401 *
402 * @return See above.
403 */
404 bool interrupt_receives();
405
406 /**
407 * Implements Persistent_mq_handle API:
408 * Turn off preemptive/concurrent interruption of blocking-receives and receivable-waits/polls.
409 *
410 * ### INFO+ logging ###
411 * WARNING on duplicate use, INFO otherwise.
412 *
413 * @return See above.
414 */
415 bool allow_receives();
416
417 /**
418 * Implements Persistent_mq_handle API: Returns name equal to `absolute_name` passed to ctor.
419 * @return See above.
420 */
421 const Shared_name& absolute_name() const;
422
423 /**
424 * Implements Persistent_mq_handle API: Returns the max message size of the underlying queue. Reminder:
425 * This is not required to match what was passed to `Create_only` or `Open_or_create` ctor.
426 *
427 * @return See above.
428 */
429 size_t max_msg_size() const;
430
431 /**
432 * Implements Persistent_mq_handle API: Returns the max message count of the underlying queue. Reminder:
433 * This is not required to match what was passed to `Create_only` or `Open_or_create` ctor.
434 *
435 * @return See above.
436 */
437 size_t max_n_msgs() const;
438
439private:
440 // Types.
441
442 /// Specifies a variation of each set (sends, receives) of operations.
443 enum class Wait_type
444 {
445 /// Poll-type (non-blocking).
446 S_POLL,
447 /// Wait-type (blocking indefinitely).
448 S_WAIT,
449 /// Timed-wait-type (blocking until timeout).
450 S_TIMED_WAIT
451 };
452
453 // Friends.
454
455 // Friend of Bipc_mq_handle.
456 friend void swap(Bipc_mq_handle& val1, Bipc_mq_handle& val2);
457
458 // Constructors/destructor.
459
460 /**
461 * Helper ctor delegated by the 2 `public` ctors that take `Open_or_create` or `Create_only` mode.
462 *
463 * @tparam Mode_tag
464 * Either util::Open_or_create or util::Create_only.
465 * @param logger_ptr
466 * See `public` ctors.
467 * @param absolute_name
468 * See `public` ctors.
469 * @param mode_tag
470 * See `public` ctors.
471 * @param max_n_msg_on_create
472 * See `public` ctors.
473 * @param max_msg_sz_on_create
474 * See `public` ctors.
475 * @param perms_on_create
476 * See `public` ctors.
477 * @param err_code
478 * See `public` ctors.
479 */
480 template<typename Mode_tag>
481 explicit Bipc_mq_handle(Mode_tag mode_tag, flow::log::Logger* logger_ptr, const Shared_name& absolute_name,
482 size_t max_n_msg_on_create, size_t max_msg_sz_on_create,
483 const util::Permissions& perms_on_create,
484 Error_code* err_code);
485
486 // Methods.
487
488 /**
489 * Error helper: Run `func()` which will perform a `bipc::message_queue` API that might throw; if it does
490 * emit an error in the way our Flow-style APIs must (set #Error_code if not null, else throw... etc.).
491 *
492 * @tparam Func
493 * Functor that takes no args and returns nothing.
494 * @param func
495 * `func()` shall be executed synchronously.
496 * @param err_code
497 * `err_code` as-if passed to our API. `*err_code` shall be set if not null depending on success/failure;
498 * if null and no problem, won't throw; if null and problem will throw `Runtime_error` containing a truthy
499 * #Error_code. That's the usual Flow-style error emission semantics.
500 * @param context
501 * Description for logging of the op being attempted, in case there is an error. Compile-time-known strings
502 * are best, as this is not protected by a filtering macro and hence will be evaluated no matter what.
503 */
504 template<typename Func>
505 void op_with_possible_bipc_mq_exception(Error_code* err_code, util::String_view context, const Func& func);
506
507 /**
508 * Impl body for `interrupt_*()` and `allow_*()`.
509 *
510 * @tparam SND_ELSE_RCV
511 * True for `*_sendable()`, else `*_receivable()`.
512 * @tparam ON_ELSE_OFF
513 * True for `interrupt_*()`, else `allow_*()`.
514 * @return See callers.
515 */
516 template<bool SND_ELSE_RCV, bool ON_ELSE_OFF>
518
519 /**
520 * Impl body for `*_sendable()` and `*_receivable()`.
521 *
522 * @tparam WAIT_TYPE
523 * See Wait_type.
524 * @tparam SND_ELSE_RCV
525 * True for `*_sendable()`, else `*_receivable()`.
526 * @param timeout_from_now
527 * `timeout_from_now` for the `timed_*()` variations; else ignored.
528 * @param err_code
529 * See callers.
530 * @return See callers.
531 */
532 template<Wait_type WAIT_TYPE, bool SND_ELSE_RCV>
533 bool wait_impl(util::Fine_duration timeout_from_now, Error_code* err_code);
534
535 // Data. ATTN: If messing with this area: don't forget to check swap()!
536
537 /**
538 * Underlying MQ handle. We are a thin wrapper around this really. Null if creation fails in ctor, or if
539 * `*this` was moved-from.
540 */
541 boost::movelib::unique_ptr<bipc::message_queue> m_mq;
542
543 /// See absolute_name().
545
546 /**
547 * Starting at `false`, this is made `true` via interrupt_sends(), and back by allow_sends(); when `true`
548 * wait_impl() will return with error::Code::S_INTERRUPTED, as checked at
549 * - the start of its wait critical section;
550 * - on being awoken via condition variable during said critical section. Said condition variable is
551 * notified by the following code:
552 * - `bipc::message_queue` opposite-direction (receiving) code, when it pops a message; and
553 * - interrupt_sends() itself when transitioning #m_interrupting_snd to `true` (also sometimes spuriously
554 * for performance).
555 *
556 * Protected by the mutex associated with the aforementioned `bipc::message_queue` condition variable.
557 * See wait_impl() internals for more detail about this mutex and all of that.
558 *
559 * (Naturally it also acts as a guard against duplicately calling interrupt_sends() or allow_sends().)
560 */
562
563 /// Other-direction counterpart to #m_interrupting_snd.
565}; // class Bipc_mq_handle
566
567// Free functions: in *_fwd.hpp.
568
569// Template implementations.
570
571template<typename Handle_name_func>
572void Bipc_mq_handle::for_each_persistent(const Handle_name_func& handle_name_func) // Static.
573{
574 /* bipc does not expose what we want; but we use the knowledge (from perusing its internal source code) that
575 * it simply stores a given MQ N's stuff in a SHM pool named also N. @todo Check Boost version or something?
576 * They could change this, although it is unlikely in my opinion (ygoldfel). */
577 util::for_each_persistent_shm_pool(handle_name_func);
578 // (See that guy's doc header for why we use him and not shm::classic::Pool_arena::for_each_persistent().)
579}
580
581} // namespace ipc::transport
Implements the Persistent_mq_handle concept by thinly wrapping bipc::message_queue,...
Bipc_mq_handle()
Implements Persistent_mq_handle API: Construct null handle.
bool allow_receives()
Implements Persistent_mq_handle API: Turn off preemptive/concurrent interruption of blocking-receives...
boost::movelib::unique_ptr< bipc::message_queue > m_mq
Underlying MQ handle.
void receive(util::Blob_mutable *blob, Error_code *err_code=nullptr)
Implements Persistent_mq_handle API: Blocking receive: pops copy of message from queue into buffer; i...
Bipc_mq_handle & operator=(Bipc_mq_handle &&src)
Implements Persistent_mq_handle API: Replaces handle with the source handle while making the latter i...
bool is_sendable(Error_code *err_code=nullptr)
Implements Persistent_mq_handle API: Like try_send() but without the actual pushing of a message.
bool timed_send(const util::Blob_const &blob, util::Fine_duration timeout_from_now, Error_code *err_code=nullptr)
Implements Persistent_mq_handle API: Blocking timed send: pushes copy of message to queue; if queue i...
static void remove_persistent(flow::log::Logger *logger_ptr, const Shared_name &absolute_name, Error_code *err_code=nullptr)
Implements Persistent_mq_handle API: Removes the named persistent MQ.
Bipc_mq_handle & operator=(const Bipc_mq_handle &)=delete
Copying of handles is prohibited, per Persistent_mq_handle concept.
Bipc_mq_handle(const Bipc_mq_handle &)=delete
Copying of handles is prohibited, per Persistent_mq_handle concept.
static void for_each_persistent(const Handle_name_func &handle_name_func)
Implements Persistent_mq_handle API.
bool m_interrupting_rcv
Other-direction counterpart to m_interrupting_snd.
bool interrupt_sends()
Implements Persistent_mq_handle API: Turn on preemptive/concurrent interruption of blocking-sends and...
bool is_receivable(Error_code *err_code=nullptr)
Implements Persistent_mq_handle API: Like try_receive() but without the actual popping of a message.
bool timed_wait_receivable(util::Fine_duration timeout_from_now, Error_code *err_code=nullptr)
Implements Persistent_mq_handle API: Like timed_receive() but without the actual popping of a message...
const Shared_name & absolute_name() const
Implements Persistent_mq_handle API: Returns name equal to absolute_name passed to ctor.
static constexpr bool S_HAS_NATIVE_HANDLE
Implements concept API.
static const Shared_name S_RESOURCE_TYPE_ID
Implements concept API.
bool allow_sends()
Implements Persistent_mq_handle API: Turn off preemptive/concurrent interruption of blocking-sends an...
Wait_type
Specifies a variation of each set (sends, receives) of operations.
bool interrupt_receives()
Implements Persistent_mq_handle API: Turn on preemptive/concurrent interruption of blocking-receives ...
bool m_interrupting_snd
Starting at false, this is made true via interrupt_sends(), and back by allow_sends(); when true wait...
Bipc_mq_handle(Bipc_mq_handle &&src)
Implements Persistent_mq_handle API: Constructs handle from the source handle while making the latter...
bool timed_wait_sendable(util::Fine_duration timeout_from_now, Error_code *err_code=nullptr)
Implements Persistent_mq_handle API: Like timed_send() but without the actual pushing of a message.
void op_with_possible_bipc_mq_exception(Error_code *err_code, util::String_view context, const Func &func)
Error helper: Run func() which will perform a bipc::message_queue API that might throw; if it does em...
size_t max_n_msgs() const
Implements Persistent_mq_handle API: Returns the max message count of the underlying queue.
void send(const util::Blob_const &blob, Error_code *err_code=nullptr)
Implements Persistent_mq_handle API: Blocking send: pushes copy of message to queue; if queue is full...
bool try_send(const util::Blob_const &blob, Error_code *err_code=nullptr)
Implements Persistent_mq_handle API: Non-blocking send: pushes copy of message to queue and returns t...
void wait_receivable(Error_code *err_code=nullptr)
Implements Persistent_mq_handle API: Like receive() but without the actual popping of a message.
~Bipc_mq_handle()
Implements Persistent_mq_handle API: Destroys this handle (or no-op if no handle was successfully con...
bool interrupt_allow_impl()
Impl body for interrupt_*() and allow_*().
bool timed_receive(util::Blob_mutable *blob, util::Fine_duration timeout_from_now, Error_code *err_code=nullptr)
Implements Persistent_mq_handle API: Blocking timed receive: pops copy of message from queue into buf...
size_t max_msg_size() const
Implements Persistent_mq_handle API: Returns the max message size of the underlying queue.
bool wait_impl(util::Fine_duration timeout_from_now, Error_code *err_code)
Impl body for *_sendable() and *_receivable().
Shared_name m_absolute_name
See absolute_name().
friend void swap(Bipc_mq_handle &val1, Bipc_mq_handle &val2)
Implements Persistent_mq_handle related concept: Swaps two objects.
void wait_sendable(Error_code *err_code=nullptr)
Implements Persistent_mq_handle API: Like send() but without the actual pushing of a message.
bool try_receive(util::Blob_mutable *blob, Error_code *err_code=nullptr)
Implements Persistent_mq_handle API: Non-blocking receive: pops copy of message from queue into buffe...
String-wrapping abstraction representing a name uniquely distinguishing a kernel-persistent entity fr...
Flow-IPC module providing transmission of structured messages and/or low-level blobs (and more) betwe...
util::Shared_name Shared_name
Convenience alias for the commonly used type util::Shared_name.
bipc::permissions Permissions
Short-hand for Unix (POSIX) permissions class.
Definition: util_fwd.hpp:158
bipc::open_only_t Open_only
Tag type indicating an ideally-atomic open-if-exists-else-fail operation.
Definition: util_fwd.hpp:152
boost::asio::mutable_buffer Blob_mutable
Short-hand for a mutable blob somewhere in memory, stored as exactly a void* and a size_t.
Definition: util_fwd.hpp:137
void for_each_persistent_shm_pool(const Handle_name_func &handle_name_func)
Equivalent to shm::classic::Pool_arena::for_each_persistent().
Definition: util.hpp:136
bipc::open_or_create_t Open_or_create
Tag type indicating an atomic open-if-exists-else-create operation.
Definition: util_fwd.hpp:149
bipc::create_only_t Create_only
Tag type indicating a create-unless-exists-else-fail operation.
Definition: util_fwd.hpp:155
flow::Fine_duration Fine_duration
Short-hand for Flow's Fine_duration.
Definition: util_fwd.hpp:114
boost::asio::const_buffer Blob_const
Short-hand for an immutable blob somewhere in memory, stored as exactly a void const * and a size_t.
Definition: util_fwd.hpp:131
flow::util::String_view String_view
Short-hand for Flow's String_view.
Definition: util_fwd.hpp:112
flow::Error_code Error_code
Short-hand for flow::Error_code which is very common.
Definition: common.hpp:313