areusch commented on a change in pull request #6603:
URL: https://github.com/apache/incubator-tvm/pull/6603#discussion_r504941656
##########
File path: src/runtime/crt/utvm_rpc_server/rpc_server.cc
##########
@@ -126,25 +125,33 @@ class MicroRPCServer {
/*! \brief Process one message from the receive buffer, if possible.
*
- * \return true if additional messages could be processed. false if the
server shutdown request
- * has been received.
+ * \param new_data If not nullptr, a pointer to a buffer pointer, which
should point at new input
+ * data to process. On return, updated to point past data that has been
consumed.
+ * \param new_data_size_bytes Points to the number of valid bytes in
`new_data`. On return,
+ * updated to the number of unprocessed bytes remaining in `new_data`
(usually 0).
+ * \return an error code indicating the outcome of the processing loop.
*/
- bool Loop() {
- if (has_pending_byte_) {
- size_t bytes_consumed;
- CHECK_EQ(unframer_.Write(&pending_byte_, 1, &bytes_consumed),
kTvmErrorNoError,
- "unframer_.Write");
- CHECK_EQ(bytes_consumed, 1, "bytes_consumed");
- has_pending_byte_ = false;
+ tvm_crt_error_t Loop(uint8_t** new_data, size_t* new_data_size_bytes) {
+ if (!is_running_) {
+ return kTvmErrorPlatformShutdown;
}
- return is_running_;
- }
+ tvm_crt_error_t err = kTvmErrorNoError;
+ // printf("loop %d %02x\n", *new_data_size_bytes, **new_data);
+ if (new_data != nullptr && new_data_size_bytes != nullptr &&
*new_data_size_bytes > 0) {
+ size_t bytes_consumed;
+ err = unframer_.Write(*new_data, *new_data_size_bytes, &bytes_consumed);
+ *new_data += bytes_consumed;
+ *new_data_size_bytes -= bytes_consumed;
+ }
- void HandleReceivedByte(uint8_t byte) {
- CHECK(!has_pending_byte_);
- has_pending_byte_ = true;
- pending_byte_ = byte;
+ if (err != kTvmErrorNoError) {
+ return err;
+ } else if (is_running_) {
+ return kTvmErrorNoError;
+ } else {
+ return kTvmErrorPlatformShutdown;
Review comment:
made this clearer now
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]