1pub struct InitSender<T>(oneshot::Sender<T>);
2
3impl<T: 'static + Send> InitSender<T> {
4 pub fn send(self, value: T) {
5 if self.0.send(value).is_err() {
6 tracing::warn!("GPU Backend finished init but receiver was dropped");
7 }
8 }
9}
10
11pub struct InitReceiver<T>(oneshot::Receiver<T>);
12
13impl<T: 'static + Send> InitReceiver<T> {
14 pub fn try_recv(&mut self) -> Result<T, oneshot::TryRecvError> {
15 self.0.try_recv()
16 }
17}
18
19pub fn init_channel<T: 'static + Send>() -> (InitSender<T>, InitReceiver<T>) {
20 let (tx, rx) = oneshot::channel();
21 (InitSender(tx), InitReceiver(rx))
22}