Skip to content

Commit

Permalink
Revert "dilation: Use async lock instead of RefCell for wormhole conn…
Browse files Browse the repository at this point in the history
…ection"

This reverts commit e9e65b4.
  • Loading branch information
felinira committed Feb 25, 2024
1 parent 94cb80a commit aeb9f7f
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/dilation/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::rc::Rc;
use std::{cell::RefCell, rc::Rc};

use futures::executor;

Expand All @@ -22,22 +22,22 @@ mod manager;
type WormholeConnection = WormholeConnectionDefault;

pub struct WormholeConnectionDefault {
wormhole: Rc<async_std::sync::Mutex<Wormhole>>,
wormhole: Rc<RefCell<Wormhole>>,
}

#[cfg_attr(test, mockall::automock)]
impl WormholeConnectionDefault {
fn new(wormhole: Wormhole) -> Self {
Self {
wormhole: Rc::new(async_std::sync::Mutex::new(wormhole)),
wormhole: Rc::new(RefCell::new(wormhole)),
}
}

async fn receive_json<T>(&self) -> Result<T, WormholeError>
where
T: for<'a> serde::Deserialize<'a> + 'static,
{
let message = self.wormhole.lock().await.receive_json().await;
let message = self.wormhole.borrow_mut().receive_json().await;
match message {
Ok(result) => match result {
Ok(result) => Ok(result),
Expand All @@ -49,8 +49,7 @@ impl WormholeConnectionDefault {

async fn send_json(&self, command: &ProtocolCommand) -> Result<(), WormholeError> {
self.wormhole
.lock()
.await
.borrow_mut()
.send_json_with_phase(command, Phase::dilation)
.await
}
Expand Down

0 comments on commit aeb9f7f

Please sign in to comment.