| 401 | |
| 402 | /// Applies \p use to the shared buffer and acknowledges the send. |
| 403 | template <bool T> template <typename U> RPC_ATTRS void Port<T>::recv(U use) { |
| 404 | // We only exchange ownership of the buffer during a receive if we are waiting |
| 405 | // for a previous receive to finish. |
| 406 | if (receive) { |
| 407 | out = process.invert_outbox(index, out); |
| 408 | owns_buffer = false; |
| 409 | } |
| 410 | |
| 411 | uint32_t in = owns_buffer ? out ^ T : process.load_inbox(lane_mask, index); |
| 412 | |
| 413 | // We need to wait until we own the buffer before receiving. |
| 414 | process.wait_for_ownership(lane_mask, index, out, in); |
| 415 | |
| 416 | // Apply the \p use function to read the memory out of the buffer. |
| 417 | invoke_rpc(use, lane_size, process.header[index].mask, |
| 418 | process.get_packet(index, lane_size)); |
| 419 | receive = true; |
| 420 | owns_buffer = true; |
| 421 | } |
| 422 | |
| 423 | /// Combines a send and receive into a single function. |
| 424 | template <bool T> |