Introduced dylib extension format, cleared up shutdown sequence

This commit is contained in:
2026-01-17 00:23:35 +01:00
parent 1a7230ce9b
commit 6a3c1d5917
18 changed files with 214 additions and 113 deletions

View File

@@ -13,7 +13,7 @@ use unsync_pipe::{Reader, Writer};
/// interactions must reflect a single logical owner
#[derive(Clone, Copy)]
#[repr(C)]
pub struct OwnedWakerVT {
pub struct OwnedWakerBin {
pub data: *const (),
/// `self`
pub drop: extern "C" fn(*const ()),
@@ -24,7 +24,7 @@ pub struct OwnedWakerVT {
}
/// !Send !Sync, equivalent to `&mut Context<'a>`, hence no `drop`.
/// When received in [FutureVT::poll], it must not outlive the call.
/// When received in [FutureBin::poll], it must not outlive the call.
///
/// You cannot directly wake using this waker, because such a trampoline would
/// pass through the binary interface twice for no reason. An efficient
@@ -33,10 +33,10 @@ pub struct OwnedWakerVT {
/// it up.
#[derive(Clone, Copy)]
#[repr(C)]
pub struct FutureContextVT {
pub struct FutureContextBin {
pub data: *const (),
/// `&self`
pub waker: extern "C" fn(*const ()) -> OwnedWakerVT,
pub waker: extern "C" fn(*const ()) -> OwnedWakerBin,
}
/// ABI-stable `Poll<()>`
@@ -53,24 +53,24 @@ pub enum UnitPoll {
/// interactions must reflect a single logical owner
#[derive(Clone, Copy)]
#[repr(C)]
pub struct FutureVT {
pub struct FutureBin {
pub data: *const (),
/// `self`
pub drop: extern "C" fn(*const ()),
/// `&mut self` Equivalent to [Future::poll]
pub poll: extern "C" fn(*const (), FutureContextVT) -> UnitPoll,
pub poll: extern "C" fn(*const (), FutureContextBin) -> UnitPoll,
}
/// Handle for a runtime that allows its holder to spawn futures across dynamic
/// library boundaries
#[derive(Clone, Copy)]
#[repr(C)]
pub struct Spawner {
pub struct SpawnerBin {
pub data: *const (),
/// `self`
pub drop: extern "C" fn(*const ()),
/// `&self` Add a future to this extension's task
pub spawn: extern "C" fn(*const (), FutureVT),
pub spawn: extern "C" fn(*const (), FutureBin),
}
/// Extension context.
@@ -80,7 +80,7 @@ pub struct Spawner {
#[repr(C)]
pub struct ExtensionContext {
/// Spawns tasks associated with this extension
pub spawner: Spawner,
pub spawner: SpawnerBin,
/// serialized [crate::HostExtChannel]
pub input: Reader,
/// serialized [crate::ExtHostChannel]