pmarks commented on code in PR #625:
URL:
https://github.com/apache/arrow-rs-object-store/pull/625#discussion_r2730938506
##########
src/util.rs:
##########
@@ -326,6 +327,23 @@ pub(crate) fn hex_encode(bytes: &[u8]) -> String {
out
}
+/// Sleep only if non-zero duration
+#[cfg(not(all(target_arch = "wasm32", any(target_os = "unknown", target_os =
"none"))))]
+pub(crate) async fn sleep(duration: Duration) {
+ if !duration.is_zero() {
+ tokio::time::sleep(duration).await
+ }
+}
+
+/// Sleep only if non-zero duration
+#[cfg(all(target_arch = "wasm32", any(target_os = "unknown", target_os =
"none")))]
+pub(crate) async fn sleep(duration: Duration) {
+ use send_wrapper::SendWrapper;
+ if !duration.is_zero() {
+ SendWrapper::new(gloo_timers::future::sleep(duration)).await
Review Comment:
The inner future is not actually Send because it contains JS objects.
SendWrapper makes it Send, with dynamic checking that it is not used on another
thread. This works for standard wasm32-unknown-unknown, and will crash 'safely'
if used across threads somehow with Web Workers, so we can figure out how to
fix that later.
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]