Skip to content

Commit

Permalink
Remove SharedLock type alias
Browse files Browse the repository at this point in the history
  • Loading branch information
temeddix committed Jun 6, 2024
1 parent 443eba8 commit 19be2d4
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 11 deletions.
5 changes: 2 additions & 3 deletions flutter_ffi_plugin/bin/src/message.dart
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,6 @@ use crate::tokio;
use prost::Message;
use rinf::send_rust_signal;
use rinf::DartSignal;
use rinf::SharedLock;
use std::sync::Mutex;
use std::sync::OnceLock;
use tokio::sync::mpsc::unbounded_channel;
Expand All @@ -271,10 +270,10 @@ use tokio::sync::mpsc::UnboundedSender;
await insertTextToFile(
rustPath,
'''
type ${messageName}Cell = SharedLock<(
type ${messageName}Cell = OnceLock<Mutex<Option<(
Option<UnboundedSender<DartSignal<${normalizePascal(messageName)}>>>,
Option<UnboundedReceiver<DartSignal<${normalizePascal(messageName)}>>>,
)>;
)>>>;
pub static ${snakeName.toUpperCase()}_CHANNEL: ${messageName}Cell =
OnceLock::new();
Expand Down
6 changes: 0 additions & 6 deletions rust_crate/src/interface.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
use std::sync::Mutex;
use std::sync::OnceLock;

#[cfg(not(target_family = "wasm"))]
use super::interface_os::*;
#[cfg(target_family = "wasm")]
use super::interface_web::*;

/// This is a mutable cell type that can be shared across threads.
pub type SharedLock<T> = OnceLock<Mutex<Option<T>>>;

/// This contains a message from Dart.
/// Optionally, a custom binary called `binary` can also be included.
/// This type is generic, and the message
Expand Down
3 changes: 1 addition & 2 deletions rust_crate/src/interface_os.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
use super::SharedLock;
use allo_isolate::IntoDart;
use allo_isolate::Isolate;
use allo_isolate::ZeroCopyBuffer;
use std::panic::catch_unwind;
use std::sync::Mutex;
use std::sync::OnceLock;

static DART_ISOLATE: SharedLock<Isolate> = OnceLock::new();
static DART_ISOLATE: OnceLock<Mutex<Option<Isolate>>> = OnceLock::new();

#[no_mangle]
pub extern "C" fn prepare_isolate_extern(port: i64) {
Expand Down

0 comments on commit 19be2d4

Please sign in to comment.