From 5677b13a86beca58aa57ecfd7cea0db7ceb189fa Mon Sep 17 00:00:00 2001 From: Dario Nieuwenhuis Date: Mon, 22 Aug 2022 22:00:06 +0200 Subject: [PATCH] sync: flatten module structure. --- embassy-lora/src/stm32wl/mod.rs | 2 +- embassy-sync/src/{channel/mpmc.rs => channel.rs} | 2 +- embassy-sync/src/channel/mod.rs | 5 ----- embassy-sync/src/lib.rs | 2 ++ embassy-sync/src/{channel => }/pubsub/mod.rs | 4 ++-- embassy-sync/src/{channel => }/pubsub/publisher.rs | 0 embassy-sync/src/{channel => }/pubsub/subscriber.rs | 0 embassy-sync/src/{channel => }/signal.rs | 2 +- examples/nrf/src/bin/channel.rs | 2 +- examples/nrf/src/bin/channel_sender_receiver.rs | 2 +- examples/nrf/src/bin/pubsub.rs | 2 +- examples/nrf/src/bin/uart_split.rs | 2 +- examples/nrf/src/bin/usb_ethernet.rs | 2 +- examples/nrf/src/bin/usb_hid_keyboard.rs | 2 +- examples/stm32f3/src/bin/button_events.rs | 2 +- examples/stm32h7/src/bin/signal.rs | 2 +- examples/stm32h7/src/bin/usart_split.rs | 2 +- examples/stm32l5/src/bin/usb_ethernet.rs | 2 +- examples/stm32wl/src/bin/subghz.rs | 2 +- 19 files changed, 18 insertions(+), 21 deletions(-) rename embassy-sync/src/{channel/mpmc.rs => channel.rs} (99%) delete mode 100644 embassy-sync/src/channel/mod.rs rename embassy-sync/src/{channel => }/pubsub/mod.rs (99%) rename embassy-sync/src/{channel => }/pubsub/publisher.rs (100%) rename embassy-sync/src/{channel => }/pubsub/subscriber.rs (100%) rename embassy-sync/src/{channel => }/signal.rs (98%) diff --git a/embassy-lora/src/stm32wl/mod.rs b/embassy-lora/src/stm32wl/mod.rs index 374c8532..7822d015 100644 --- a/embassy-lora/src/stm32wl/mod.rs +++ b/embassy-lora/src/stm32wl/mod.rs @@ -12,7 +12,7 @@ use embassy_stm32::subghz::{ Status, SubGhz, TcxoMode, TcxoTrim, Timeout, TxParams, }; use embassy_stm32::Peripheral; -use embassy_sync::channel::signal::Signal; +use embassy_sync::signal::Signal; use lorawan_device::async_device::radio::{Bandwidth, PhyRxTx, RfConfig, RxQuality, SpreadingFactor, TxConfig}; use lorawan_device::async_device::Timings; diff --git a/embassy-sync/src/channel/mpmc.rs b/embassy-sync/src/channel.rs similarity index 99% rename from embassy-sync/src/channel/mpmc.rs rename to embassy-sync/src/channel.rs index 7bebd341..76f42d0e 100644 --- a/embassy-sync/src/channel/mpmc.rs +++ b/embassy-sync/src/channel.rs @@ -373,7 +373,7 @@ where /// Establish a new bounded channel. For example, to create one with a NoopMutex: /// /// ``` - /// use embassy_sync::channel::mpmc::Channel; + /// use embassy_sync::channel::Channel; /// use embassy_sync::blocking_mutex::raw::NoopRawMutex; /// /// // Declare a bounded channel of 3 u32s. diff --git a/embassy-sync/src/channel/mod.rs b/embassy-sync/src/channel/mod.rs deleted file mode 100644 index 5df1f5c5..00000000 --- a/embassy-sync/src/channel/mod.rs +++ /dev/null @@ -1,5 +0,0 @@ -//! Async channels - -pub mod mpmc; -pub mod pubsub; -pub mod signal; diff --git a/embassy-sync/src/lib.rs b/embassy-sync/src/lib.rs index 7d881590..8e81e5cb 100644 --- a/embassy-sync/src/lib.rs +++ b/embassy-sync/src/lib.rs @@ -14,4 +14,6 @@ pub mod blocking_mutex; pub mod channel; pub mod mutex; pub mod pipe; +pub mod pubsub; +pub mod signal; pub mod waitqueue; diff --git a/embassy-sync/src/channel/pubsub/mod.rs b/embassy-sync/src/pubsub/mod.rs similarity index 99% rename from embassy-sync/src/channel/pubsub/mod.rs rename to embassy-sync/src/pubsub/mod.rs index f62b4d11..62a9e476 100644 --- a/embassy-sync/src/channel/pubsub/mod.rs +++ b/embassy-sync/src/pubsub/mod.rs @@ -34,8 +34,8 @@ pub use subscriber::{DynSubscriber, Subscriber}; /// /// ``` /// # use embassy_sync::blocking_mutex::raw::NoopRawMutex; -/// # use embassy_sync::channel::pubsub::WaitResult; -/// # use embassy_sync::channel::pubsub::PubSubChannel; +/// # use embassy_sync::pubsub::WaitResult; +/// # use embassy_sync::pubsub::PubSubChannel; /// # use futures_executor::block_on; /// # let test = async { /// // Create the channel. This can be static as well diff --git a/embassy-sync/src/channel/pubsub/publisher.rs b/embassy-sync/src/pubsub/publisher.rs similarity index 100% rename from embassy-sync/src/channel/pubsub/publisher.rs rename to embassy-sync/src/pubsub/publisher.rs diff --git a/embassy-sync/src/channel/pubsub/subscriber.rs b/embassy-sync/src/pubsub/subscriber.rs similarity index 100% rename from embassy-sync/src/channel/pubsub/subscriber.rs rename to embassy-sync/src/pubsub/subscriber.rs diff --git a/embassy-sync/src/channel/signal.rs b/embassy-sync/src/signal.rs similarity index 98% rename from embassy-sync/src/channel/signal.rs rename to embassy-sync/src/signal.rs index 9279266c..3f665e38 100644 --- a/embassy-sync/src/channel/signal.rs +++ b/embassy-sync/src/signal.rs @@ -19,7 +19,7 @@ use core::task::{Context, Poll, Waker}; /// Signals are generally declared as `static`s and then borrowed as required. /// /// ``` -/// use embassy_sync::channel::signal::Signal; +/// use embassy_sync::signal::Signal; /// /// enum SomeCommand { /// On, diff --git a/examples/nrf/src/bin/channel.rs b/examples/nrf/src/bin/channel.rs index 8371fd0a..d782a79e 100644 --- a/examples/nrf/src/bin/channel.rs +++ b/examples/nrf/src/bin/channel.rs @@ -6,7 +6,7 @@ use defmt::unwrap; use embassy_executor::Spawner; use embassy_nrf::gpio::{Level, Output, OutputDrive}; use embassy_sync::blocking_mutex::raw::ThreadModeRawMutex; -use embassy_sync::channel::mpmc::Channel; +use embassy_sync::channel::Channel; use embassy_time::{Duration, Timer}; use {defmt_rtt as _, panic_probe as _}; diff --git a/examples/nrf/src/bin/channel_sender_receiver.rs b/examples/nrf/src/bin/channel_sender_receiver.rs index 55d1fccb..fcccdaed 100644 --- a/examples/nrf/src/bin/channel_sender_receiver.rs +++ b/examples/nrf/src/bin/channel_sender_receiver.rs @@ -6,7 +6,7 @@ use defmt::unwrap; use embassy_executor::Spawner; use embassy_nrf::gpio::{AnyPin, Level, Output, OutputDrive, Pin}; use embassy_sync::blocking_mutex::raw::NoopRawMutex; -use embassy_sync::channel::mpmc::{Channel, Receiver, Sender}; +use embassy_sync::channel::{Channel, Receiver, Sender}; use embassy_time::{Duration, Timer}; use static_cell::StaticCell; use {defmt_rtt as _, panic_probe as _}; diff --git a/examples/nrf/src/bin/pubsub.rs b/examples/nrf/src/bin/pubsub.rs index 64fed641..688e6d07 100644 --- a/examples/nrf/src/bin/pubsub.rs +++ b/examples/nrf/src/bin/pubsub.rs @@ -5,7 +5,7 @@ use defmt::unwrap; use embassy_executor::Spawner; use embassy_sync::blocking_mutex::raw::ThreadModeRawMutex; -use embassy_sync::channel::pubsub::{DynSubscriber, PubSubChannel, Subscriber}; +use embassy_sync::pubsub::{DynSubscriber, PubSubChannel, Subscriber}; use embassy_time::{Duration, Timer}; use {defmt_rtt as _, panic_probe as _}; diff --git a/examples/nrf/src/bin/uart_split.rs b/examples/nrf/src/bin/uart_split.rs index 88b9c0a8..1adaf53f 100644 --- a/examples/nrf/src/bin/uart_split.rs +++ b/examples/nrf/src/bin/uart_split.rs @@ -8,7 +8,7 @@ use embassy_nrf::peripherals::UARTE0; use embassy_nrf::uarte::UarteRx; use embassy_nrf::{interrupt, uarte}; use embassy_sync::blocking_mutex::raw::ThreadModeRawMutex; -use embassy_sync::channel::mpmc::Channel; +use embassy_sync::channel::Channel; use {defmt_rtt as _, panic_probe as _}; static CHANNEL: Channel = Channel::new(); diff --git a/examples/nrf/src/bin/usb_ethernet.rs b/examples/nrf/src/bin/usb_ethernet.rs index 0200d880..ca6c7e0d 100644 --- a/examples/nrf/src/bin/usb_ethernet.rs +++ b/examples/nrf/src/bin/usb_ethernet.rs @@ -15,7 +15,7 @@ use embassy_nrf::rng::Rng; use embassy_nrf::usb::{Driver, PowerUsb}; use embassy_nrf::{interrupt, pac, peripherals}; use embassy_sync::blocking_mutex::raw::ThreadModeRawMutex; -use embassy_sync::channel::mpmc::Channel; +use embassy_sync::channel::Channel; use embassy_usb::{Builder, Config, UsbDevice}; use embassy_usb_ncm::{CdcNcmClass, Receiver, Sender, State}; use embedded_io::asynch::{Read, Write}; diff --git a/examples/nrf/src/bin/usb_hid_keyboard.rs b/examples/nrf/src/bin/usb_hid_keyboard.rs index d7c6dafd..ba2159c7 100644 --- a/examples/nrf/src/bin/usb_hid_keyboard.rs +++ b/examples/nrf/src/bin/usb_hid_keyboard.rs @@ -12,7 +12,7 @@ use embassy_futures::{select, Either}; use embassy_nrf::gpio::{Input, Pin, Pull}; use embassy_nrf::usb::{Driver, PowerUsb}; use embassy_nrf::{interrupt, pac}; -use embassy_sync::channel::signal::Signal; +use embassy_sync::signal::Signal; use embassy_usb::control::OutResponse; use embassy_usb::{Builder, Config, DeviceStateHandler}; use embassy_usb_hid::{HidReaderWriter, ReportId, RequestHandler, State}; diff --git a/examples/stm32f3/src/bin/button_events.rs b/examples/stm32f3/src/bin/button_events.rs index edf34b4d..02c475f6 100644 --- a/examples/stm32f3/src/bin/button_events.rs +++ b/examples/stm32f3/src/bin/button_events.rs @@ -16,7 +16,7 @@ use embassy_stm32::exti::ExtiInput; use embassy_stm32::gpio::{AnyPin, Input, Level, Output, Pin, Pull, Speed}; use embassy_stm32::peripherals::PA0; use embassy_sync::blocking_mutex::raw::ThreadModeRawMutex; -use embassy_sync::channel::mpmc::Channel; +use embassy_sync::channel::Channel; use embassy_time::{with_timeout, Duration, Timer}; use {defmt_rtt as _, panic_probe as _}; diff --git a/examples/stm32h7/src/bin/signal.rs b/examples/stm32h7/src/bin/signal.rs index ae41b07a..cc3e4e3c 100644 --- a/examples/stm32h7/src/bin/signal.rs +++ b/examples/stm32h7/src/bin/signal.rs @@ -4,7 +4,7 @@ use defmt::{info, unwrap}; use embassy_executor::Spawner; -use embassy_sync::channel::signal::Signal; +use embassy_sync::signal::Signal; use embassy_time::{Duration, Timer}; use {defmt_rtt as _, panic_probe as _}; diff --git a/examples/stm32h7/src/bin/usart_split.rs b/examples/stm32h7/src/bin/usart_split.rs index 55630dd3..df2b600f 100644 --- a/examples/stm32h7/src/bin/usart_split.rs +++ b/examples/stm32h7/src/bin/usart_split.rs @@ -8,7 +8,7 @@ use embassy_stm32::dma::NoDma; use embassy_stm32::peripherals::{DMA1_CH1, UART7}; use embassy_stm32::usart::{Config, Uart, UartRx}; use embassy_sync::blocking_mutex::raw::ThreadModeRawMutex; -use embassy_sync::channel::mpmc::Channel; +use embassy_sync::channel::Channel; use {defmt_rtt as _, panic_probe as _}; #[embassy_executor::task] diff --git a/examples/stm32l5/src/bin/usb_ethernet.rs b/examples/stm32l5/src/bin/usb_ethernet.rs index b21d8629..3286f5c4 100644 --- a/examples/stm32l5/src/bin/usb_ethernet.rs +++ b/examples/stm32l5/src/bin/usb_ethernet.rs @@ -16,7 +16,7 @@ use embassy_stm32::time::Hertz; use embassy_stm32::usb::Driver; use embassy_stm32::{interrupt, Config}; use embassy_sync::blocking_mutex::raw::ThreadModeRawMutex; -use embassy_sync::channel::mpmc::Channel; +use embassy_sync::channel::Channel; use embassy_usb::{Builder, UsbDevice}; use embassy_usb_ncm::{CdcNcmClass, Receiver, Sender, State}; use embedded_io::asynch::{Read, Write}; diff --git a/examples/stm32wl/src/bin/subghz.rs b/examples/stm32wl/src/bin/subghz.rs index 6d54e850..c5e9bb59 100644 --- a/examples/stm32wl/src/bin/subghz.rs +++ b/examples/stm32wl/src/bin/subghz.rs @@ -13,7 +13,7 @@ use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; use embassy_stm32::interrupt; use embassy_stm32::interrupt::{Interrupt, InterruptExt}; use embassy_stm32::subghz::*; -use embassy_sync::channel::signal::Signal; +use embassy_sync::signal::Signal; use {defmt_rtt as _, panic_probe as _}; const PING_DATA: &str = "PING";