You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -432,6 +433,7 @@ A delegate container stores one or more delegates. A delegate container is calla
432
433
```cpp
433
434
// Delegate Containers
434
435
UnicastDelegate<>
436
+
UnicastDelegateSafe<>
435
437
MulticastDelegate<>
436
438
MulticastDelegateSafe<>
437
439
```
@@ -966,6 +968,7 @@ DelegateBase
966
968
967
969
// Delegate Containers
968
970
UnicastDelegate<>
971
+
UnicastDelegateSafe<>
969
972
MulticastDelegate<>
970
973
MulticastDelegateSafe<>
971
974
```
@@ -1097,6 +1100,8 @@ There is no way to asynchronously pass a C-style array by value. Avoid C-style a
1097
1100
1098
1101
# Interfaces
1099
1102
1103
+
DelegateMQ interface classes allow customizing the library runtime behavior.
1104
+
1100
1105
## `IThread`
1101
1106
1102
1107
The `IThread` interface is used to send a delegate and argument data through a message queue. A delegate thread is required to dispatch asynchronous delegates to a specified target thread. The delegate library automatically constructs a `DelegateMsg` containing everything necessary for the destination thread.
@@ -1600,6 +1605,106 @@ void AsyncFutureExample()
1600
1605
comm_thread.ExitThread();
1601
1606
}
1602
1607
```
1608
+
## Remote Delegate Example
1609
+
1610
+
Use a remote delegate to invoke a remote target function using [MessagePack](https://github.com/msgpack/msgpack-c/tree/cpp_master) (serialization) and [ZeroMQ](https://zeromq.org/) (transport). Code snippets below express the concept. See [system-architecture](#system-architecture) to execute this example.
1611
+
1612
+
`NetworkMgr` class used by client and server applications handles communication with remote device. `SendAlarmMsg()` sends a message to the remote. `AlarmMsgCb` callback is used to receive the incoming message.
1613
+
1614
+
```cpp
1615
+
#include "DelegateMQ.h"
1616
+
1617
+
// NetworkMgr sends and receives data using a DelegateMQ transport implemented
At runtime, setup the remote delegate interface. A key point is the remote delegate (`m_alarmMsgDel`) binds directly to the `AlarmMsgCb` container (`dmq::MulticastDelegateSafe<AlarmFunc>`). Every incoming message generates one or more callbacks to registered listeners by binding `m_alarmMsgDel` remote delegate to the `AlarmMsgCb` container. A delegate may bind to any callable, and a delegate container is callable.
1652
+
1653
+
```cpp
1654
+
intNetworkMgr::Create()
1655
+
{
1656
+
// Reinvoke call onto NetworkMgr thread
1657
+
if (Thread::GetCurrentThreadId() != m_thread.GetThreadId())
Send message to the remote by calling the `m_alarmMsgDel` delegate on `m_thread` context. A ZeroMQ socket instance is not thread safe so ZeroMQ socket access is always on the `NetworkMgr` internal thread.
See the `examples/sample-code` directory for additional examples.
@@ -1610,7 +1715,7 @@ See the `examples/sample-projects` directory for example project. Most projects
1610
1715
1611
1716
### system-architecture
1612
1717
1613
-
The System Architecture example demonstrates a complex client-server DelegateMQ application using the ZeroMQ and MessagePack support libraries. This example implements the acquisition of sensor and actuator data across two applications. It showcases communication and collaboration between subsystems, threads, and processes or processors. Delegate communication, callbacks, asynchronous APIs, and error handing are also highlighted. Notice how easily DelegateMQ transfers event data between threads and processes with minimal application code.
1718
+
The System Architecture example demonstrates a complex client-server DelegateMQ application using the ZeroMQ and MessagePack support libraries. This example implements the acquisition of sensor and actuator data across two applications. It showcases communication and collaboration between subsystems, threads, and processes or processors. Delegate communication, callbacks, asynchronous APIs, and error handing are also highlighted. Notice how easily DelegateMQ transfers event data between threads and processes with minimal application code. The application layer is completely isolated from message passing details.
1614
1719
1615
1720
Execute the client and server projects to run the example.
0 commit comments