Skip to content

Commit 56aeeb2

Browse files
committed
remove async from tests
1 parent 0ad53b7 commit 56aeeb2

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

src/slice.rs

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -80,34 +80,39 @@ impl<T: Sized> BufferExt for T {}
8080
/// }
8181
///
8282
/// impl<Buf: WriteBuffer> DmaTransfer<Buf> {
83+
/// /// stars the DMA transfer
8384
/// fn start(buf: Buf) -> Self {
84-
/// // DMA logic
85+
/// // DMA logic would go here
8586
/// Self { buf }
8687
/// }
8788
///
88-
/// async fn wait_until_done(&self) {
89-
/// // to implement
89+
/// /// returns if DMA transaction is done.
90+
/// /// this could be called in a polling loop in order to be non-blocking
91+
/// fn is_done(&self) -> bool {
92+
/// true
9093
/// }
9194
///
95+
/// /// returns resources held by the DMA transfer.
9296
/// fn free(self) -> Buf {
9397
/// // busy loop which waits until DMA is done to ensure safety
98+
/// while !self.is_done() {}
9499
/// self.buf
95100
/// }
96101
/// }
97102
///
98103
/// /// This function is bad because we cannot obtain the original slice—just a subset of it.
99-
/// async fn dma_transfer_bad1(buffer: &'static mut [u8], length: usize) -> &'static [u8] {
104+
/// fn dma_transfer_bad1(buffer: &'static mut [u8], length: usize) -> &'static [u8] {
100105
/// let sub_slice = &mut buffer[..length];
101106
/// let transfer = DmaTransfer::start(sub_slice);
102-
/// transfer.wait_until_done().await;
107+
/// while !transfer.is_done() {}
103108
/// transfer.free()
104109
/// }
105110
///
106111
/// /// This function is bad because we cannot unsplit the slice.
107-
/// async fn dma_transfer_bad2(buffer: &'static mut [u8], length: usize) -> &'static [u8] {
112+
/// fn dma_transfer_bad2(buffer: &'static mut [u8], length: usize) -> &'static [u8] {
108113
/// let (slice_a, slice_b) = buffer.split_at_mut(length);
109114
/// let transfer = DmaTransfer::start(slice_a);
110-
/// transfer.wait_until_done().await;
115+
/// while !transfer.is_done() {}
111116
/// let slice_a = transfer.free();
112117
/// // can't unsplit!!!
113118
/// slice_a
@@ -117,8 +122,7 @@ impl<T: Sized> BufferExt for T {}
117122
/// fn dma_transfer(buffer: &'static mut [u8], length: usize) -> &'static [u8] {
118123
/// let buffer_slice = buffer.into_buffer_slice(..length);
119124
/// let transfer = DmaTransfer::start(buffer_slice);
120-
/// // we are commenting this out so we can actually test it without an async runtime
121-
/// // transfer.wait_until_done().await;
125+
/// while !transfer.is_done() {}
122126
/// let buffer_slice = transfer.free();
123127
/// buffer_slice.inner()
124128
/// }

0 commit comments

Comments
 (0)