OGLplus  (0.59.0) a C++ wrapper for rendering APIs

loopback.hpp
Go to the documentation of this file.
1 
9 #ifndef EAGINE_MESSAGE_BUS_LOOPBACK_HPP
10 #define EAGINE_MESSAGE_BUS_LOOPBACK_HPP
11 
12 #include "connection.hpp"
13 #include <mutex>
14 
15 namespace eagine::msgbus {
16 //------------------------------------------------------------------------------
20 public:
21  auto kind() -> connection_kind final {
23  }
24 
25  auto addr_kind() -> connection_addr_kind final {
27  }
28 
29  auto type_id() -> identifier final {
30  return EAGINE_ID(Loopback);
31  }
32 
33  auto send(message_id msg_id, const message_view& message) -> bool final {
34  std::unique_lock lock{_mutex};
35  _messages.push(msg_id, message);
36  return true;
37  }
38 
39  auto fetch_messages(connection::fetch_handler handler) -> bool final {
40  std::unique_lock lock{_mutex};
41  return _messages.fetch_all(handler);
42  }
43 
44 private:
45  std::mutex _mutex;
46  message_storage _messages;
47 };
48 //------------------------------------------------------------------------------
49 } // namespace eagine::msgbus
50 
51 #endif // EAGINE_MESSAGE_BUS_LOOPBACK_HPP
Declaration of class template storing a reference to a callable object.
Definition: callable_ref.hpp:24
#define EAGINE_ID(NAME)
Macro for constructing instances of eagine::identifier.
Definition: identifier.hpp:353
auto fetch_all(fetch_handler handler) -> bool
Fetches all currently stored messages and calls handler on them.
Loopback implementation of connection. Used mainly for testing and development.
Definition: loopback.hpp:19
auto fetch_messages(connection::fetch_handler handler) -> bool final
Fetch all enqueued messages that have been received since last fetch.
Definition: loopback.hpp:39
Interface for message bus connections.
Definition: connection.hpp:114
@ in_process
In-process connection (cannot be used for inter-process communication).
auto kind() -> connection_kind final
Returns the connection kind.
Definition: loopback.hpp:21
Combines message information and a non-owning view to message content.
Definition: message.hpp:288
Message bus code is placed in this namespace.
Definition: eagine.hpp:58
auto addr_kind() -> connection_addr_kind final
Returns the connection address kind.
Definition: loopback.hpp:25
connection_addr_kind
Message bus connection address kind enumeration.
Definition: connection.hpp:30
auto send(message_id msg_id, const message_view &message) -> bool final
Sent a message with the specified id.
Definition: loopback.hpp:33
connection_kind
Message bus connection kind bits enumeration.
Definition: connection_kind.hpp:21
Class storing message bus messages.
Definition: message.hpp:446
void push(message_id msg_id, const message_view &message)
Pushes a message into this storage.
Definition: message.hpp:464
Class storing two identifier values representing class/method pair.
Definition: message_id.hpp:25
auto type_id() -> identifier final
Returns a description identifier of the implementation.
Definition: loopback.hpp:29

Copyright © 2015-2021 Matúš Chochlík.
<chochlik -at -gmail.com>
Documentation generated on Tue Apr 13 2021 by Doxygen (version 1.8.17).