-
Notifications
You must be signed in to change notification settings - Fork 4
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
WIP: Add AppWorkload builder & Cycle checking #4
Conversation
Co-authored-by: leudz <[email protected]>
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.
A number of nits and some questions. 👍 on the test additions, and nice wins (the line numbers increase is due to adding Cargo.lock
and tests).
pub fn add_plugin_workload<P>(&mut self, plugin: P) -> AppWorkload | ||
where | ||
P: Plugin + 'static, |
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.
I usually put the generics right in the definition if the line doesn't get too wide:
pub fn add_plugin_workload<P>(&mut self, plugin: P) -> AppWorkload | |
where | |
P: Plugin + 'static, | |
pub fn add_plugin_workload<P: Plugin + 'static>(&mut self, plugin: P) -> AppWorkload |
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.
The following fn (add_plugin_workload_with_info
) has the same structure but does become too wide for one line, so I'm leaning towards the two signatures reading the same way.
self.add_plugin_workload_with_info(plugin).0 | ||
} | ||
|
||
#[track_caller] |
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.
Does trace_span!
obey #[track_caller]
? Or is there any possible panic I overlooked?
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.
builder.finish_with_info_named
unwraps on the "add to world" step
use crate::{App, AppWorkload, AppWorkloadInfo, PluginAssociated, TypeIdBuckets}; | ||
|
||
#[derive(Clone)] | ||
pub struct CyclePluginAssociations { |
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.
Some documentation would be nice. What's a cycle here?
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.
I'll add some docs!
} | ||
/// If you override this to return true, then you will be allowed to add your plugin multiple times. | ||
fn can_add_multiple_times(&self) -> bool { | ||
false | ||
} | ||
} |
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.
If we decide to create a macro to build an impl for this, here would be a good place to put it.
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.
Hmmm... I feel like there's some niceties we could apply using a DSL of some kind, but the impls are pretty lightweight overall IMO.
} | ||
} | ||
|
||
unsafe impl<'a, T: 'static + Send + Sync> BorrowInfo for Tracked<'a, T> { |
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 an interesting concept; but I don't understand what BorrowInfo
does, yet. Note to self: Need to look into this at some point.
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.
Don't look too closely right now since it's being reworked a bit by @leudz.
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.
BorrowInfo
collects information about what each system borrows, this is used by WorkloadBuilder
to decide scheduling inside a workload.
The borrow_info
function was previously in Borrow
, I moved it to its own trait to make it unsafe
. I will add a way to bypass locking and trust the scheduler.
But the scheduler can only do correctly its job if BorrowInfo
is implemented correctly.
enum InnerTrackedState { | ||
New, | ||
Modified, | ||
NoChanges, |
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.
NoChanges, | |
Unchanged, |
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.
Any precedent for this rename or just preference?
|
||
#[inline(always)] | ||
fn deref(&self) -> &T { | ||
&self.0 .1 |
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.
load-bearing whitespace? Is some parser confused and thinks this was a float? rustc would accept &self.0.1
.
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.
cargo fmt
/ rustfmt
did this, I think.
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.
Oops! I just saw that you already merged. So perhaps there should be a followup PR. |
Changes to enable detection of workload conflicts.