Skip to content

Commit

Permalink
desktop: Remove Session drop order guarantee.
Browse files Browse the repository at this point in the history
It is no longer used.
  • Loading branch information
kpreid committed Dec 14, 2024
1 parent cd2c902 commit f6d11dc
Showing 1 changed file with 0 additions and 47 deletions.
47 changes: 0 additions & 47 deletions all-is-cubes-desktop/src/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@ use crate::Session;
/// Wraps a basic [`Session`] to add functionality that is common within
/// all-is-cubes-desktop's scope of supported usage (such as loading a universe
/// from disk).
///
/// This type guarantees that the `renderer` will be dropped before the `window`;
/// `unsafe` graphics code may rely on this.
#[derive(Debug)]
pub struct DesktopSession<Ren, Win> {
#[allow(missing_docs)]
Expand Down Expand Up @@ -233,47 +230,3 @@ pub enum ClockSource {
/// by the specified amount.
Fixed(Duration),
}

#[cfg(test)]
mod tests {
use super::*;

#[tokio::test]
async fn drop_order() {
use std::sync::mpsc;

struct DropLogger {
sender: mpsc::Sender<&'static str>,
message: &'static str,
}
impl Drop for DropLogger {
fn drop(&mut self) {
self.sender.send(self.message).unwrap();
}
}
impl crate::glue::Window for DropLogger {
fn set_title(&self, _: String) {}
}

let (sender, receiver) = mpsc::channel();
drop(DesktopSession::new(
crate::Executor::new(tokio::runtime::Handle::current()),
DropLogger {
sender: sender.clone(),
message: "renderer",
},
DropLogger {
sender,
message: "window",
},
Session::builder().build().await,
ListenableCell::new(Viewport::ARBITRARY),
false,
));

assert_eq!(
receiver.into_iter().collect::<Vec<_>>(),
vec!["renderer", "window"]
);
}
}

0 comments on commit f6d11dc

Please sign in to comment.