Skip to content

Commit

Permalink
remove locks (#71)
Browse files Browse the repository at this point in the history
  • Loading branch information
KennethKnudsen97 authored Feb 6, 2025
1 parent 2c5757d commit 3e2cad0
Showing 1 changed file with 0 additions and 13 deletions.
13 changes: 0 additions & 13 deletions src/shadows/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,6 @@ where
mqtt: &'m embedded_mqtt::MqttClient<'a, M>,
subscription: Mutex<NoopRawMutex, Option<embedded_mqtt::Subscription<'a, 'm, M, 2>>>,
_shadow: PhantomData<S>,
// request_lock is used to ensure that shadow operations such as subscribing, updating, or
// deleting are serialized, preventing multiple concurrent requests to the same MQTT topics.
request_lock: Mutex<NoopRawMutex, ()>,
}

impl<'a, 'm, M: RawMutex, S: ShadowState> ShadowHandler<'a, 'm, M, S>
Expand Down Expand Up @@ -106,8 +103,6 @@ where
/// Internal helper function for applying a delta state to the actual shadow
/// state, and update the cloud shadow.
async fn report<R: Serialize>(&self, reported: &R) -> Result<(), Error> {
let _update_requested_lock = self.request_lock.lock().await;

debug!(
"[{:?}] Updating reported shadow value.",
S::NAME.unwrap_or(CLASSIC_SHADOW),
Expand Down Expand Up @@ -185,8 +180,6 @@ where

/// Initiate a `GetShadow` request, updating the local state from the cloud.
async fn get_shadow(&self) -> Result<DeltaState<S::PatchState>, Error> {
let _get_requested_lock = self.request_lock.lock().await;

//Wait for mqtt to connect
self.mqtt.wait_connected().await;

Expand Down Expand Up @@ -233,8 +226,6 @@ where
}

pub async fn delete_shadow(&self) -> Result<(), Error> {
let _delete_request = self.request_lock.lock().await;

// Wait for mqtt to connect
self.mqtt.wait_connected().await;

Expand Down Expand Up @@ -266,8 +257,6 @@ where
}

pub async fn create_shadow(&self) -> Result<DeltaState<S::PatchState>, Error> {
let _create_requested_lock = self.request_lock.lock().await;

debug!(
"[{:?}] Creating initial shadow value.",
S::NAME.unwrap_or(CLASSIC_SHADOW),
Expand Down Expand Up @@ -413,7 +402,6 @@ where
mqtt,
subscription: Mutex::new(None),
_shadow: PhantomData,
request_lock: Mutex::new(()),
};

Self {
Expand Down Expand Up @@ -537,7 +525,6 @@ where
mqtt,
subscription: Mutex::new(None),
_shadow: PhantomData,
request_lock: Mutex::new(()),
};
Self { handler, state }
}
Expand Down

0 comments on commit 3e2cad0

Please sign in to comment.