| 99 | } |
| 100 | |
| 101 | void UURLabZmqRpcTransport::RunPollLoop() |
| 102 | { |
| 103 | while (!bStop.load(std::memory_order_acquire)) |
| 104 | { |
| 105 | zmq_msg_t Msg; |
| 106 | zmq_msg_init(&Msg); |
| 107 | int rc = zmq_msg_recv(&Msg, ZmqRep, 0); |
| 108 | if (rc < 0) |
| 109 | { |
| 110 | zmq_msg_close(&Msg); |
| 111 | // Timeout or shutdown — loop and check bStop. |
| 112 | continue; |
| 113 | } |
| 114 | |
| 115 | const int Size = zmq_msg_size(&Msg); |
| 116 | TArray<uint8> InBytes; |
| 117 | InBytes.SetNumUninitialized(Size); |
| 118 | if (Size > 0) |
| 119 | FMemory::Memcpy(InBytes.GetData(), zmq_msg_data(&Msg), Size); |
| 120 | zmq_msg_close(&Msg); |
| 121 | |
| 122 | // Wire detect / parse / dispatch / encode all live on the base. |
| 123 | TArray<uint8> OutBytes; |
| 124 | ProcessRequestBytes(InBytes, OutBytes); |
| 125 | zmq_send(ZmqRep, OutBytes.GetData(), OutBytes.Num(), 0); |
| 126 | } |
| 127 | } |