Skip to content
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 checks to config #57

Merged
merged 2 commits into from Mar 28, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 4 additions & 1 deletion core/src/runtime.rs
Expand Up @@ -181,6 +181,7 @@ impl KompactConfig {
/// Larger values can increase throughput on highly loaded components,
/// but at the cost of fairness between components.
pub fn throughput(&mut self, n: usize) -> &mut Self {
assert!(n > 0, "throughput must be larger than 0");
self.throughput = n;
self
}
Expand All @@ -194,6 +195,7 @@ impl KompactConfig {
/// the remaining allotment will be redistributed to the other type
/// until all throughput is used up or no messages or events remain.
pub fn msg_priority(&mut self, r: f32) -> &mut Self {
assert!(r > 0.0, "msg_priority must be larger than 0.0");
self.msg_priority = r;
self
}
Expand All @@ -205,6 +207,7 @@ impl KompactConfig {
/// You *must* ensure that the selected [scheduler](KompactConfig::scheduler) implementation
/// can manage the given number of threads, if you customise this value!
pub fn threads(&mut self, n: usize) -> &mut Self {
assert!(n > 0, "threads must be larger than 0");
self.threads = n;
self
}
Expand Down Expand Up @@ -437,7 +440,7 @@ impl Default for KompactConfig {
/// It runs with one thread per cpu on an appropriately sized [`crossbeam_workstealing_pool`](crossbeam_workstealing_pool) implementation.
/// It uses all default components, without networking, with the default timer and default logger.
fn default() -> Self {
let threads = num_cpus::get();
let threads = std::cmp::max(1, num_cpus::get());
let scheduler_builder: Rc<SchedulerBuilder> = if threads <= 32 {
Rc::new(|t| ExecutorScheduler::from(crossbeam_workstealing_pool::small_pool(t)))
} else if threads <= 64 {
Expand Down