Skip to content

Commit 7edc576

Browse files
committed
letsplay_runner_core: Cleanup
move transport module to shared/ so that it's all nice and good
1 parent 0aff4c5 commit 7edc576

5 files changed

Lines changed: 22 additions & 17 deletions

File tree

crates/letsplay_runner_core/src/client/game_thread.rs

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,8 @@ fn main(mut rx: mpsc::UnboundedReceiver<GameThreadMessage>, mut game: Box<dyn Ga
4343
// better (and properly handle states or whatever) we should probably just like... Do so?
4444
let mut suspended = true;
4545

46-
// bring up EGL/CUDA/whatever
47-
4846
let contexts = GraphicsContexts::create(0);
4947

50-
// Spawn the video thread here
51-
5248
let (video_encoder_control, packet_waiter) = {
5349
#[cfg(feature = "av-nvidia")]
5450
{
@@ -102,7 +98,8 @@ fn main(mut rx: mpsc::UnboundedReceiver<GameThreadMessage>, mut game: Box<dyn Ga
10298
}
10399

104100
GameThreadMessage::SetProperty { key, value, tx } => {
105-
// TODO: set_property should be failable
101+
// TODO: we should send the error result to the given tx
102+
// so that we can propegate errors to the main thread
106103
match game.set_property(&key, &value) {
107104
Ok(_) => {}
108105
Err(err) => {
@@ -175,14 +172,13 @@ impl GameThread {
175172
}
176173

177174
pub async fn reset(&self) {
178-
// TODO
179175
let (tx, rx) = oneshot::channel();
180176
let _ = self.tx.send(GameThreadMessage::Reset { tx });
181177
let _ = rx.await;
182178
}
183179

184180
pub async fn set_property(&self, key: String, value: String) {
185-
// TODO
181+
// TODO: This should be failable
186182
let (tx, rx) = oneshot::channel();
187183
let _ = self.tx.send(GameThreadMessage::SetProperty {
188184
key: key.clone(),
@@ -202,8 +198,8 @@ impl GameThread {
202198
}
203199

204200
/// Shuts down the game thread.
205-
pub async fn shutdown(&self) {
201+
pub async fn shutdown(self) {
206202
let _ = self.tx.send(GameThreadMessage::Shutdown);
207-
// TODO: join thread (or make it easier for this to be consuming)
203+
self.join_handle.join().expect("Failed to join game thread");
208204
}
209205
}

crates/letsplay_runner_core/src/client/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
mod game;
44
mod game_thread;
55
mod graphics_contexts;
6-
mod transport;
76

87
pub use game::*;
98
pub use graphics_contexts::*;

crates/letsplay_runner_core/src/client/transport.rs

Lines changed: 0 additions & 7 deletions
This file was deleted.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
pub mod proto;
2+
mod transport;
3+
// pub use transport::Transport;, probably
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
//
2+
// struct Transport<RW>
3+
// where
4+
// RW: AsyncRead + AsyncWrite + ...
5+
//
6+
// - generic over literally anything that can be read or wtitten as a stream
7+
//
8+
// Use tokio util length delimited codec
9+
// https://docs.rs/tokio-util/latest/tokio_util/codec/length_delimited/index.html
10+
//
11+
// Have two helpers to pull out/parse protos of the each end's roots
12+
// (or fail cleanly)
13+
//
14+
// guess if we *really* wanted to (I don't see it being needed since we'll only own it in
15+
// a fairly flat way) we could have ReadTransport<R> and WriteTransport<W> but idk

0 commit comments

Comments
 (0)