| 145 | |
| 146 | |
| 147 | void Runtime::RuntimeProcess::loop() |
| 148 | { |
| 149 | void* tag; |
| 150 | bool ok; |
| 151 | |
| 152 | while (queue.Next(&tag, &ok)) { |
| 153 | // Currently only unary RPCs are supported, so `ok` should always be true. |
| 154 | // See: https://grpc.io/grpc/cpp/classgrpc_1_1_completion_queue.html#a86d9810ced694e50f7987ac90b9f8c1a // NOLINT |
| 155 | CHECK(ok); |
| 156 | |
| 157 | // Obtain the tag as a `ReceiveCallback` and dispatch it to the runtime |
| 158 | // process. The tag is then reclaimed here. |
| 159 | ReceiveCallback* callback = reinterpret_cast<ReceiveCallback*>(tag); |
| 160 | dispatch(self(), &RuntimeProcess::receive, std::move(*callback)); |
| 161 | delete callback; |
| 162 | } |
| 163 | |
| 164 | // Terminate self after all events are drained. |
| 165 | process::terminate(self(), false); |
| 166 | } |
| 167 | |
| 168 | |
| 169 | Runtime::Data::Data() |