-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Basic working multi-driver demo using async bbq #3
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is awesome!
i had some tiny unimportant suggestions, take them or leave them
Co-authored-by: Eliza Weisman <eliza@buoyant.io>
Co-authored-by: Eliza Weisman <eliza@buoyant.io>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 on the Arc
, this is definitely a lot nicer...we can probably bring back the NonNull
s as an optimization to avoid the field access, if it's necessary, but this feels like a safer starting point.
some tiny suggestions on the tracing stuff, but no blockers from me
"Got bbqueue max write grant", | ||
); | ||
return GrantW { | ||
grant: wgr, | ||
side: self.side, | ||
storage: self.storage.clone(), | ||
} | ||
}, | ||
Err(_) => { | ||
trace!("awaiting bbqueue max write grant"); | ||
// Uh oh! Couldn't get a send grant. We need to wait for the OTHER reader | ||
// to release some bytes first. | ||
match self.side { | ||
Side::ASide => &self.storage.b_wait, | ||
Side::BSide => &self.storage.a_wait, | ||
}.release_waitcell.wait().await.unwrap(); | ||
|
||
trace!("awoke for bbqueue max write grant"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit, take it or leave it: maybe worth sticking
"Got bbqueue max write grant", | |
); | |
return GrantW { | |
grant: wgr, | |
side: self.side, | |
storage: self.storage.clone(), | |
} | |
}, | |
Err(_) => { | |
trace!("awaiting bbqueue max write grant"); | |
// Uh oh! Couldn't get a send grant. We need to wait for the OTHER reader | |
// to release some bytes first. | |
match self.side { | |
Side::ASide => &self.storage.b_wait, | |
Side::BSide => &self.storage.a_wait, | |
}.release_waitcell.wait().await.unwrap(); | |
trace!("awoke for bbqueue max write grant"); | |
side = ?self.side, | |
"Got bbqueue max write grant", | |
); | |
return GrantW { | |
grant: wgr, | |
side: self.side, | |
storage: self.storage.clone(), | |
} | |
}, | |
Err(_) => { | |
trace!(side = ?self.side, max, "awaiting bbqueue max write grant"); | |
// Uh oh! Couldn't get a send grant. We need to wait for the OTHER reader | |
// to release some bytes first. | |
match self.side { | |
Side::ASide => &self.storage.b_wait, | |
Side::BSide => &self.storage.a_wait, | |
}.release_waitcell.wait().await.unwrap(); | |
trace!(side = ?self.side, max, "awoke for bbqueue max write grant"); |
trace!( | ||
size = size, | ||
"Got bbqueue exact write grant", | ||
); | ||
return GrantW { | ||
grant: wgr, | ||
side: self.side, | ||
storage: self.storage.clone(), | ||
} | ||
}, | ||
Err(_) => { | ||
trace!("awaiting bbqueue exact write grant"); | ||
// Uh oh! Couldn't get a send grant. We need to wait for the OTHER reader | ||
// to release some bytes first. | ||
match self.side { | ||
Side::ASide => &self.storage.b_wait, | ||
Side::BSide => &self.storage.a_wait, | ||
}.release_waitcell.wait().await.unwrap(); | ||
trace!("awoke for bbqueue exact write grant"); | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
trace!( | |
size = size, | |
"Got bbqueue exact write grant", | |
); | |
return GrantW { | |
grant: wgr, | |
side: self.side, | |
storage: self.storage.clone(), | |
} | |
}, | |
Err(_) => { | |
trace!("awaiting bbqueue exact write grant"); | |
// Uh oh! Couldn't get a send grant. We need to wait for the OTHER reader | |
// to release some bytes first. | |
match self.side { | |
Side::ASide => &self.storage.b_wait, | |
Side::BSide => &self.storage.a_wait, | |
}.release_waitcell.wait().await.unwrap(); | |
trace!("awoke for bbqueue exact write grant"); | |
}, | |
trace!( | |
size = size, | |
side = ?self.side, | |
"Got bbqueue exact write grant", | |
); | |
return GrantW { | |
grant: wgr, | |
side: self.side, | |
storage: self.storage.clone(), | |
} | |
}, | |
Err(_) => { | |
trace!(side = ?self.side, size, "awaiting bbqueue exact write grant"); | |
// Uh oh! Couldn't get a send grant. We need to wait for the OTHER reader | |
// to release some bytes first. | |
match self.side { | |
Side::ASide => &self.storage.b_wait, | |
Side::BSide => &self.storage.a_wait, | |
}.release_waitcell.wait().await.unwrap(); | |
trace!(side = ?self.side, size, "awoke for bbqueue exact write grant"); | |
}, |
size = rgr.len(), | ||
"Got bbqueue read grant", | ||
); | ||
return GrantR { | ||
grant: rgr, | ||
side: self.side, | ||
storage: self.storage.clone(), | ||
} | ||
}, | ||
Err(_) => { | ||
trace!("awaiting bbqueue read grant"); | ||
// Uh oh! Couldn't get a read grant. We need to wait for the OTHER writer | ||
// to commit some bytes first. | ||
match self.side { | ||
Side::ASide => &self.storage.b_wait.commit_waitcell, | ||
Side::BSide => &self.storage.a_wait.commit_waitcell, | ||
}.wait().await.unwrap(); | ||
trace!("awoke for bbqueue read grant"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
size = rgr.len(), | |
"Got bbqueue read grant", | |
); | |
return GrantR { | |
grant: rgr, | |
side: self.side, | |
storage: self.storage.clone(), | |
} | |
}, | |
Err(_) => { | |
trace!("awaiting bbqueue read grant"); | |
// Uh oh! Couldn't get a read grant. We need to wait for the OTHER writer | |
// to commit some bytes first. | |
match self.side { | |
Side::ASide => &self.storage.b_wait.commit_waitcell, | |
Side::BSide => &self.storage.a_wait.commit_waitcell, | |
}.wait().await.unwrap(); | |
trace!("awoke for bbqueue read grant"); | |
size = rgr.len(), | |
side = ?self.side, | |
"Got bbqueue read grant", | |
); | |
return GrantR { | |
grant: rgr, | |
side: self.side, | |
storage: self.storage.clone(), | |
} | |
}, | |
Err(_) => { | |
trace!(side = ?self.side, "awaiting bbqueue read grant"); | |
// Uh oh! Couldn't get a read grant. We need to wait for the OTHER writer | |
// to commit some bytes first. | |
match self.side { | |
Side::ASide => &self.storage.b_wait.commit_waitcell, | |
Side::BSide => &self.storage.a_wait.commit_waitcell, | |
}.wait().await.unwrap(); | |
trace!(side = ?self.side, "awoke for bbqueue read grant"); |
match self.producer.grant_exact(size) { | ||
Ok(wgr) => { | ||
trace!( | ||
size = size, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tiny nit: this could just be
size = size, | |
size, |
Ok(wgr) => { | ||
trace!( | ||
size = wgr.len(), | ||
max = max, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: could just be
max = max, | |
max, |
This implements a quad-waitcell version of bbq, as well as a basic PoC with two sort-of drivers. This data structure is intended for drivers such as a serial port.