Replace use of Arc<RwLock<T>> with Shared<T>
This commit is contained in:
parent
92654989e8
commit
39b1f1fa72
|
@ -42,8 +42,8 @@ impl GatewayHandle {
|
|||
|
||||
pub async fn observe<T: Updateable + Clone + Debug + Composite<T>>(
|
||||
&self,
|
||||
object: Arc<RwLock<T>>,
|
||||
) -> Arc<RwLock<T>> {
|
||||
object: Shared<T>,
|
||||
) -> Shared<T> {
|
||||
let mut store = self.store.lock().await;
|
||||
let id = object.read().unwrap().id();
|
||||
if let Some(channel) = store.get(&id) {
|
||||
|
@ -84,7 +84,7 @@ impl GatewayHandle {
|
|||
/// with all of its observable fields being observed.
|
||||
pub async fn observe_and_into_inner<T: Updateable + Clone + Debug + Composite<T>>(
|
||||
&self,
|
||||
object: Arc<RwLock<T>>,
|
||||
object: Shared<T>,
|
||||
) -> T {
|
||||
let channel = self.observe(object.clone()).await;
|
||||
let object = channel.read().unwrap().clone();
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
use std::sync::{Arc, RwLock};
|
||||
|
||||
use chorus::gateway::Gateway;
|
||||
use chorus::gateway::{Gateway, Shared};
|
||||
use chorus::types::Composite;
|
||||
use chorus::{
|
||||
instance::{ChorusUser, Instance},
|
||||
types::{
|
||||
|
@ -16,9 +15,9 @@ pub(crate) struct TestBundle {
|
|||
pub urls: UrlBundle,
|
||||
pub user: ChorusUser,
|
||||
pub instance: Instance,
|
||||
pub guild: Arc<RwLock<Guild>>,
|
||||
pub role: Arc<RwLock<RoleObject>>,
|
||||
pub channel: Arc<RwLock<Channel>>,
|
||||
pub guild: Shared<Guild>,
|
||||
pub role: Shared<RoleObject>,
|
||||
pub channel: Shared<Channel>,
|
||||
}
|
||||
|
||||
#[allow(unused)]
|
||||
|
@ -119,9 +118,9 @@ pub(crate) async fn setup() -> TestBundle {
|
|||
urls,
|
||||
user,
|
||||
instance,
|
||||
guild: Arc::new(RwLock::new(guild)),
|
||||
role: Arc::new(RwLock::new(role)),
|
||||
channel: Arc::new(RwLock::new(channel)),
|
||||
guild: guild.to_shared(),
|
||||
role: role.to_shared(),
|
||||
channel: channel.to_shared(),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue