Last active
August 8, 2018 17:34
-
-
Save gterzian/fcf955a56c7ef96d8bc1ca77ddeffc72 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for msg in gen_port { | |
// Receive generated numbers from the "generate" stage. | |
let generated_num = match msg { | |
PipelineMsg::Generated(num) => num, | |
_ => panic!("unexpected message receiving from gen stage"), | |
}; | |
// Cycle through the workers and distribute work. | |
let worker = square_workers.pop_front().unwrap(); | |
let _ = worker.send(msg); | |
square_workers.push_back(worker); | |
if generated_num == 3 { | |
// Once we get the "last number" we need, | |
// we just stop iterating, | |
// dropping the gen_port, and stopping the generator thread. | |
break; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment