Rename SyncLazy to LazyLock

This commit is contained in:
decentclock
2022-06-20 09:27:48 -06:00
parent 495459b74e
commit 89e1ee1429
2 changed files with 4 additions and 5 deletions

View File

@@ -8,7 +8,7 @@ use librumqttd::{
use std::sync::Arc;
use std::thread;
use std::time::Duration;
use std::{lazy::SyncLazy, sync::Mutex};
use std::sync::{LazyLock, Mutex};
use tokio::sync::mpsc;
use tokio::time::timeout;
@@ -19,7 +19,7 @@ const PASSWORD: &str = "sphinx-key-pass";
// must get a reply within this time, or disconnects
const REPLY_TIMEOUT_MS: u64 = 10000;
static CONNECTED: SyncLazy<Mutex<bool>> = SyncLazy::new(|| Mutex::new(false));
static CONNECTED: LazyLock<Mutex<bool>> = LazyLock::new(|| Mutex::new(false));
fn set_connected(b: bool) {
*CONNECTED.lock().unwrap() = b;
}

View File

@@ -6,10 +6,9 @@ use esp_idf_hal::peripherals::Peripherals;
use esp_idf_hal::rmt::config::TransmitConfig;
use esp_idf_hal::rmt::{FixedLengthSignal, PinState, Pulse, Transmit};
use std::lazy::SyncLazy;
use std::sync::Mutex;
use std::sync::{LazyLock, Mutex};
static TX: SyncLazy<Mutex<Transmit<Gpio8<esp_idf_hal::gpio::Output>, esp_idf_hal::rmt::CHANNEL0>>> = SyncLazy::new(|| {
static TX: LazyLock<Mutex<Transmit<Gpio8<esp_idf_hal::gpio::Output>, esp_idf_hal::rmt::CHANNEL0>>> = LazyLock::new(|| {
let peripherals = Peripherals::take().unwrap();
let led = peripherals.pins.gpio8.into_output().unwrap();
let channel = peripherals.rmt.channel0;