comments and abort

This commit is contained in:
2024-08-24 00:35:54 -04:00
parent 3cf3dc5936
commit 7aab854a6b
2 changed files with 8 additions and 7 deletions

View File

@ -21,7 +21,7 @@ pub struct Dispatch {
impl Dispatch {
pub fn new() -> Dispatch {
let (s, r) = unbounded();
let (s, r) = unbounded(); //This should always be unbounded, because some callbacks have to send_blocking to it, and if the thread blocks, other tasks can't empty the queue!
let mut hmap = HashMap::new();
hmap.reserve(Commands::COUNT);
Dispatch { callbacks: hmap, recv: r, endpoint: s}
@ -29,7 +29,7 @@ impl Dispatch {
/// Get a channel receiver that will get callbacks for all commands in the listen_for vec.
pub fn get_callback_channel(&mut self, listen_for: &Vec<Commands>) -> RecvQ {
let (send, rec) = unbounded();
let (send, rec) = unbounded(); // TODO: these could be bounded instead, as these calls are all non-blocking.
for cmd in listen_for {
let callback_list = self.callbacks.get_mut(&discriminant(&cmd));
match callback_list {
@ -48,9 +48,6 @@ impl Dispatch {
rec
}
//TODO: Make a discriminant version of this function that takes a vec of discriminants
//TODO: Most of these channels could be fixed size instead unbound; probably only the incomming channel needs to be large.
/// Get a channel sender that will send commands to this dispatcher
pub fn get_cmd_channel(&mut self) -> SendQ {
self.endpoint.clone()