kylebarron commented on code in PR #625:
URL: 
https://github.com/apache/arrow-rs-object-store/pull/625#discussion_r3399360343


##########
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:
   I wonder if perhaps we should create our own type that is `Send` whenever 
the target arch is not `wasm32`?
   
   I.e.
   ```rs
   //! `MaybeSend` and `MaybeSync` traits for cross-platform async code.
   //!
   //! Reference: 
<https://github.com/iced-rs/iced/blob/master/futures/src/maybe.rs>
   
   #[cfg(not(target_arch = "wasm32"))]
   mod platform {
       /// A marker trait that enforces `Send` only on native platforms.
       ///
       pub use core::marker::Send as MaybeSend;
       /// A marker trait that enforces `Sync` only on native platforms.
       ///
       pub use core::marker::Sync as MaybeSync;
   }
   
   #[cfg(target_arch = "wasm32")]
   mod platform {
       /// A marker trait that enforces `Send` only on native platforms.
       pub trait MaybeSend {}
   
       impl<T> MaybeSend for T {}
   
       /// A marker trait that enforces `Sync` only on native platforms.
       pub trait MaybeSync {}
   
       impl<T> MaybeSync for T {}
   }
   
   pub use platform::{MaybeSend, MaybeSync};
   ```
   
   from 
https://github.com/zarrs/zarrs/blob/77aeab716ea219049f372ea750eecce4b72fbb7f/zarrs_plugin/src/maybe.rs#L1-L28



-- 
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]

Reply via email to