|
@@ -1,6 +1,6 @@
|
|
|
-use std::{rc::Rc, borrow::BorrowMut};
|
|
|
use std::cell::RefCell;
|
|
|
use std::ops::DerefMut;
|
|
|
+use std::{borrow::BorrowMut, rc::Rc};
|
|
|
|
|
|
use crate::io::{FleckIO, Packet};
|
|
|
|
|
@@ -57,20 +57,36 @@ pub trait OutgoingPriority {
|
|
|
#[macro_export]
|
|
|
macro_rules! service_priority {
|
|
|
($what:ty, in: $i:ty, out: $o:ty) => {
|
|
|
- impl fleck::service::IncomingPriority for $what { type Priority = $i; }
|
|
|
- impl fleck::service::OutgoingPriority for $what { type Priority = $o; }
|
|
|
+ impl fleck::service::IncomingPriority for $what {
|
|
|
+ type Priority = $i;
|
|
|
+ }
|
|
|
+ impl fleck::service::OutgoingPriority for $what {
|
|
|
+ type Priority = $o;
|
|
|
+ }
|
|
|
};
|
|
|
($what:ty, in: $i:ty) => {
|
|
|
- impl fleck::service::IncomingPriority for $what { type Priority = $i; }
|
|
|
- impl fleck::service::OutgoingPriority for $what { type Priority = fleck::service::order::Never; }
|
|
|
+ impl fleck::service::IncomingPriority for $what {
|
|
|
+ type Priority = $i;
|
|
|
+ }
|
|
|
+ impl fleck::service::OutgoingPriority for $what {
|
|
|
+ type Priority = fleck::service::order::Never;
|
|
|
+ }
|
|
|
};
|
|
|
($what:ty, out: $o:ty) => {
|
|
|
- impl fleck::service::IncomingPriority for $what { type Priority = fleck::service::order::Never; }
|
|
|
- impl fleck::service::OutgoingPriority for $what { type Priority = $o; }
|
|
|
+ impl fleck::service::IncomingPriority for $what {
|
|
|
+ type Priority = fleck::service::order::Never;
|
|
|
+ }
|
|
|
+ impl fleck::service::OutgoingPriority for $what {
|
|
|
+ type Priority = $o;
|
|
|
+ }
|
|
|
};
|
|
|
($what:ty) => {
|
|
|
- impl fleck::service::IncomingPriority for $what { type Priority = fleck::service::order::Never; }
|
|
|
- impl fleck::service::OutgoingPriority for $what { type Priority = fleck::service::order::Never; }
|
|
|
+ impl fleck::service::IncomingPriority for $what {
|
|
|
+ type Priority = fleck::service::order::Never;
|
|
|
+ }
|
|
|
+ impl fleck::service::OutgoingPriority for $what {
|
|
|
+ type Priority = fleck::service::order::Never;
|
|
|
+ }
|
|
|
};
|
|
|
}
|
|
|
|
|
@@ -108,46 +124,58 @@ impl ServiceStack {
|
|
|
|
|
|
self.services.push(srv.clone());
|
|
|
if !<<S as IncomingPriority>::Priority as AbstractServicePriority>::NEVER {
|
|
|
- self.incoming_order.add_priority::<<S as IncomingPriority>::Priority>(srv.clone());
|
|
|
+ self.incoming_order
|
|
|
+ .add_priority::<<S as IncomingPriority>::Priority>(srv.clone());
|
|
|
}
|
|
|
if !<<S as OutgoingPriority>::Priority as AbstractServicePriority>::NEVER {
|
|
|
- self.incoming_order.add_priority::<<S as OutgoingPriority>::Priority>(srv.clone());
|
|
|
+ self.incoming_order
|
|
|
+ .add_priority::<<S as OutgoingPriority>::Priority>(srv.clone());
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
impl Service for ServiceStack {
|
|
|
fn process_incoming(&mut self, api: &dyn API, packet: &mut Packet) {
|
|
|
- let services = self.incoming_cache.get_or_insert_with(|| {
|
|
|
- self.incoming_order.clone().order()
|
|
|
- });
|
|
|
+ let services = self
|
|
|
+ .incoming_cache
|
|
|
+ .get_or_insert_with(|| self.incoming_order.clone().order());
|
|
|
|
|
|
for srv in services {
|
|
|
- srv.as_ref().borrow_mut().deref_mut().process_incoming(api, packet);
|
|
|
+ srv.as_ref()
|
|
|
+ .borrow_mut()
|
|
|
+ .deref_mut()
|
|
|
+ .process_incoming(api, packet);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
fn process_outgoing(&mut self, api: &dyn API, packet: &mut Packet) {
|
|
|
- let services = self.outgoing_cache.get_or_insert_with(|| {
|
|
|
- self.outgoing_order.clone().order()
|
|
|
- });
|
|
|
+ let services = self
|
|
|
+ .outgoing_cache
|
|
|
+ .get_or_insert_with(|| self.outgoing_order.clone().order());
|
|
|
|
|
|
for srv in services {
|
|
|
- srv.as_ref().borrow_mut().deref_mut().process_incoming(api, packet);
|
|
|
+ srv.as_ref()
|
|
|
+ .borrow_mut()
|
|
|
+ .deref_mut()
|
|
|
+ .process_incoming(api, packet);
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
|
|
|
fn process_minor_tick(&mut self, api: &dyn API) {
|
|
|
for srv in &self.services {
|
|
|
- srv.as_ref().borrow_mut().deref_mut().process_minor_tick(api);
|
|
|
+ srv.as_ref()
|
|
|
+ .borrow_mut()
|
|
|
+ .deref_mut()
|
|
|
+ .process_minor_tick(api);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
fn process_major_tick(&mut self, api: &dyn API) {
|
|
|
for srv in &self.services {
|
|
|
- srv.as_ref().borrow_mut().deref_mut().process_major_tick(api);
|
|
|
+ srv.as_ref()
|
|
|
+ .borrow_mut()
|
|
|
+ .deref_mut()
|
|
|
+ .process_major_tick(api);
|
|
|
}
|
|
|
}
|
|
|
}
|