From 0992071a7f1a36424bcfaf1fbc84541ea041df1a Mon Sep 17 00:00:00 2001 From: hozan23 Date: Thu, 11 Apr 2024 10:19:20 +0200 Subject: add support for tokio & improve net crate api --- core/src/pubsub.rs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'core/src/pubsub.rs') diff --git a/core/src/pubsub.rs b/core/src/pubsub.rs index f5cb69b..bcc24ef 100644 --- a/core/src/pubsub.rs +++ b/core/src/pubsub.rs @@ -1,9 +1,8 @@ use std::{collections::HashMap, sync::Arc}; use log::error; -use smol::lock::Mutex; -use crate::{util::random_16, Result}; +use crate::{async_runtime::lock::Mutex, util::random_16, Result}; pub type ArcPublisher = Arc>; pub type SubscriptionID = u16; @@ -28,7 +27,7 @@ pub type SubscriptionID = u16; /// /// ``` pub struct Publisher { - subs: Mutex>>, + subs: Mutex>>, } impl Publisher { @@ -43,7 +42,7 @@ impl Publisher { pub async fn subscribe(self: &Arc) -> Subscription { let mut subs = self.subs.lock().await; - let chan = smol::channel::unbounded(); + let chan = async_channel::unbounded(); let mut sub_id = random_16(); @@ -84,7 +83,7 @@ impl Publisher { // Subscription pub struct Subscription { id: SubscriptionID, - recv_chan: smol::channel::Receiver, + recv_chan: async_channel::Receiver, publisher: ArcPublisher, } @@ -93,7 +92,7 @@ impl Subscription { pub fn new( id: SubscriptionID, publisher: ArcPublisher, - recv_chan: smol::channel::Receiver, + recv_chan: async_channel::Receiver, ) -> Subscription { Self { id, -- cgit v1.2.3