xloop_types 0.1.2

core types for xloop.
Documentation
use super::Platform;
pub trait AppDelegate<P: Platform>: 'static {
	fn on_launch(&self, _: P::AppRef<'_>) {}
	fn on_terminate(&self, _: P::AppRef<'_>) {}
}
pub trait AppRef<P: Platform> {
	fn terminate(&self);
	fn proxy(&self) -> Option<P::AppProxy>;
}
pub trait AppHandle<P: Platform>: Sized {
	fn singleton() -> Option<Self>;
	fn with(&self, _: impl FnMut(P::AppRef<'_>));
}
pub trait AppProxy: Sized + Send + Sync + 'static {
	fn wake(&self, id: i64);
	fn to_waker(self, id: i64) -> core::task::Waker {
		struct AppWaker<T: AppProxy>(T, i64);
		impl<T: AppProxy> std::task::Wake for AppWaker<T> {
			fn wake(self: std::sync::Arc<Self>) {
				self.0.wake(self.1);
			}
		}
		std::sync::Arc::new(AppWaker(self, id)).into()
	}
}