-
Notifications
You must be signed in to change notification settings - Fork 221
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
Add a PlannerBuilder #104
Add a PlannerBuilder #104
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.
I wonder why you want to have a builder at all? There is only 2 ways to create a planner: with given thread pool or without. So it sounds like Planner
could just have 2 different constructors, let's say new
and with_thread_pool
. Did you consider this?
src/planner.rs
Outdated
/// threads, a new thread pool with the number of virtual | ||
/// cpus will be created. | ||
pub struct PlannerBuilder { | ||
world: Option<World>, |
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.
what is the point of having an Option
here in the first place?
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.
Yes, I thought about using with_thread_pool
, but I thought it's not descriptive enough because you still have another parameter. Yes, you are right I could have asked for world already in the builder constructor, but I think it is nicer to use. Of course it's not compile-time enforced then.
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.
Plus, now the pool size defaults to the number of cpus, which should be pretty common. I do have another solution in mind, though:
enum PoolOptions {
Pool(Arc<ThreadPool>),
NumThreads(usize),
NumCpus,
}
impl Planner {
pub fn from_options(options: PoolOptions) -> Self {
}
}
How about we have just |
I found a non-breaking way, using a trait |
@torkleyy I don't think it's worth it. Let's not have a fancy API, let's have a simple one, with |
So you mean I should just take a plain |
No, I mean that we don't even need a constructor that takes |
Maybe add a And from the user's perspective it isn't obvious that the way you get a |
Closing because title does not match the content anymore. #106 replaces this PR |
This allows sharing the thread pool, which is pretty important for highly parallel applications in order to allow a good performance.
Sorry I've done so bad in my previous PR, I hope this one is better.