Skip to content

Instantly share code, notes, and snippets.

@gterzian
Created August 8, 2018 08:31
Show Gist options
  • Save gterzian/716ca1a98ad09e592fdc6f5a545ee719 to your computer and use it in GitHub Desktop.
Save gterzian/716ca1a98ad09e592fdc6f5a545ee719 to your computer and use it in GitHub Desktop.
// Handle the msg from the select.
let result = match msg {
// We got work from the producer...
MainMsg::FromProducer(ProducerMsg::Incoming(workflow)) => {
// Send info to the consumer, telling it to expect this piece of work
// This is really just for testing in this case...
let _ = consumer_sender.send(ConsumerMsg::ExpectWorkflow(workflow.id));
if let Some(executor) = executor_queue.pop_front() {
// Send work to the worker at the front of the qeue.
let _ = executor.send(ExecutorMsg::Execute(workflow));
executor_queue.push_back(executor);
}
// Start waiting for the next message.
// Note we're not assigning anything to "result" here...
continue;
},
// We got a result from the consumer,
// Assign it to "result" for further processing below...
MainMsg::FromConsumer(msg) => msg
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment