aboutsummaryrefslogtreecommitdiff
path: root/pw_sys_io
diff options
context:
space:
mode:
authorKeir Mierle <keir@google.com>2020-11-06 14:04:00 -0800
committerCQ Bot Account <pigweed-scoped@luci-project-accounts.iam.gserviceaccount.com>2020-11-07 01:17:28 +0000
commit6909f18e6b7a710743dce4b6fe8005a8c1cf6365 (patch)
tree0cb7609e431bfc8d7de23e46a6afe164a779f31c /pw_sys_io
parent878bd196fe858f85edbb1dd6a992998c37de343c (diff)
downloadpigweed-6909f18e6b7a710743dce4b6fe8005a8c1cf6365.tar.gz
pw_sys_io: Add TryReadByte(byte* dest) function
This adds a non-blocking version of ReadByte() that enables writing, for example, a superloop that combines custom processing simultaneously with byte input handling for the RPC subsystem. Change-Id: I9cb1e6ae8c944ca7cdff6d4bff101ac52e80b53a Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/23980 Reviewed-by: Armando Montanez <amontanez@google.com> Commit-Queue: Keir Mierle <keir@google.com>
Diffstat (limited to 'pw_sys_io')
-rw-r--r--pw_sys_io/public/pw_sys_io/sys_io.h11
1 files changed, 10 insertions, 1 deletions
diff --git a/pw_sys_io/public/pw_sys_io/sys_io.h b/pw_sys_io/public/pw_sys_io/sys_io.h
index 5973579fc..477c71967 100644
--- a/pw_sys_io/public/pw_sys_io/sys_io.h
+++ b/pw_sys_io/public/pw_sys_io/sys_io.h
@@ -51,9 +51,18 @@ namespace pw::sys_io {
// This function will block until it either succeeds or fails to read a byte
// from the pw_sys_io backend.
//
-// Returns Status::Ok() if a byte was successfully read.
+// Returns Status::Ok() - A byte was successfully read.
+// Status::ResourceExhausted() - if the underlying source vanished.
Status ReadByte(std::byte* dest);
+// Read a single byte from the sys io backend, if available.
+// Implemented by: Backend
+//
+// Returns Status::Ok() - A byte was successfully read, and is in dest.
+// Status::Unavailable() - No byte is available to read; try later.
+// Status::Unimplemented() - Not supported on this target.
+Status TryReadByte(std::byte* dest);
+
// Write a single byte out the sys io backend.
// Implemented by: Backend
//