Created
May 11, 2020 05:06
-
-
Save gterzian/1f5e663ac3fe216dda94fbad71b5f03a 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
// Spawn the "payment" service. | |
let _ = thread::spawn(move || loop { | |
match payment_request_receiver.recv() { | |
Ok(PaymentRequest::NewOrder(order_id)) => { | |
// Process the payment for a new order. | |
let _ = payment_result_sender.send(PaymentResult(order_id, true)); | |
} | |
Ok(PaymentRequest::ShutDown) => { | |
break; | |
} | |
Err(_) => panic!("Error receiving a payment request."), | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment