1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
use compt::Depth;
pub trait Joiner: Send + Sync + Copy + Clone {
fn into_seq(&self) -> Sequential;
fn should_switch_to_sequential(&self, a: Depth) -> bool;
}
#[derive(Copy, Clone)]
pub struct Parallel(pub Depth);
impl Parallel {
pub fn new(d: Depth) -> Self {
Parallel(d)
}
}
impl Joiner for Parallel {
fn into_seq(&self) -> Sequential {
Sequential
}
fn should_switch_to_sequential(&self, a: Depth) -> bool {
a.0 >= (self.0).0
}
}
#[derive(Copy, Clone)]
pub struct Sequential;
impl Joiner for Sequential {
fn into_seq(&self) -> Sequential {
Sequential
}
fn should_switch_to_sequential(&self, _a: Depth) -> bool {
true
}
}