Skip to content

Commit

Permalink
Merge pull request #57 from Max-Meldrum/small_checks
Browse files Browse the repository at this point in the history
Add checks to config
  • Loading branch information
Bathtor committed Mar 28, 2020
2 parents 1e5fc6c + b57b6b2 commit 8f0f026
Showing 1 changed file with 4 additions and 1 deletion.
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

0 comments on commit 8f0f026

Please sign in to comment.