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