feat: Dispatcher constructor separates render_rx
The dispatcher no longer owns the render results message channel, and instead passes it out as a separate item during construction.
This commit is contained in:
@@ -66,8 +66,7 @@ fn main() {
|
||||
};
|
||||
|
||||
thread::scope(|s| {
|
||||
let mut dispatcher = thread_utils::Dispatcher::new(&small_rng);
|
||||
let scanline_receiver = dispatcher.render_rx;
|
||||
let (mut dispatcher, mut scanline_receiver) = thread_utils::Dispatcher::new(&small_rng);
|
||||
|
||||
s.spawn(move || {
|
||||
for y in (0..image.1).rev() {
|
||||
|
||||
@@ -30,11 +30,10 @@ pub struct Dispatcher{
|
||||
handles: Vec<thread::JoinHandle<()>>,
|
||||
command_transmitters: Vec<mpsc::SyncSender<RenderCommand>>,
|
||||
next_to_feed: usize, // gonna do a round-robin style dispatch, ig.
|
||||
pub render_rx: mpsc::Receiver<RenderResult>,
|
||||
}
|
||||
|
||||
impl Dispatcher {
|
||||
pub fn new(srng: &SmallRng) -> Dispatcher {
|
||||
pub fn new(srng: &SmallRng) -> (Dispatcher, mpsc::Receiver<RenderResult> ) {
|
||||
let mut handles = Vec::new();
|
||||
let mut command_transmitters = Vec::<mpsc::SyncSender<RenderCommand>>::new();
|
||||
|
||||
@@ -67,13 +66,14 @@ impl Dispatcher {
|
||||
command_transmitters.push(command_tx);
|
||||
}
|
||||
// finally, stash everything in the Dispatcher struct and return.
|
||||
|
||||
Dispatcher{
|
||||
handles,
|
||||
command_transmitters,
|
||||
next_to_feed: 0,
|
||||
render_rx,
|
||||
}
|
||||
(
|
||||
Dispatcher{
|
||||
handles,
|
||||
command_transmitters,
|
||||
next_to_feed: 0,
|
||||
},
|
||||
render_rx
|
||||
)
|
||||
}
|
||||
|
||||
//TODO: Reconsider round-robin dispatch
|
||||
|
||||
Reference in New Issue
Block a user