Skip to content

Commit

Permalink
wasi: Remove vbus leftovers and improve task joining
Browse files Browse the repository at this point in the history
* A new TaskStatus is introduced that specifies the current state of a task
  (usually a process or thread)
* Status tracking is refactored to use tokio::sync::watch instead of a
  homegrown solution which combined channels and mutexes
* The task status now not just tracks an exit code, but also the ocurred error
  This helps consumers of the task status to know that and error
  ocurred, and which one, which helps debugging / logging and potential
  recovery
* Remove the unused VBUS crate leftover types and traits
  Almost all gone, except for the VirtualBusError
* Move SignalHandlerAbi types to os::signal
  • Loading branch information
theduke committed Feb 25, 2023
1 parent 871ff53 commit c98ccaf
Show file tree
Hide file tree
Showing 26 changed files with 427 additions and 849 deletions.
150 changes: 1 addition & 149 deletions lib/wasi-types/src/wasi/bindings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1117,52 +1117,7 @@ impl core::fmt::Debug for Tty {
.finish()
}
}
#[repr(u8)]
#[derive(Clone, Copy, PartialEq, Eq)]
pub enum BusDataFormat {
Raw,
Bincode,
MessagePack,
Json,
Yaml,
Xml,
Rkyv,
}
impl core::fmt::Debug for BusDataFormat {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
match self {
BusDataFormat::Raw => f.debug_tuple("BusDataFormat::Raw").finish(),
BusDataFormat::Bincode => f.debug_tuple("BusDataFormat::Bincode").finish(),
BusDataFormat::MessagePack => f.debug_tuple("BusDataFormat::MessagePack").finish(),
BusDataFormat::Json => f.debug_tuple("BusDataFormat::Json").finish(),
BusDataFormat::Yaml => f.debug_tuple("BusDataFormat::Yaml").finish(),
BusDataFormat::Xml => f.debug_tuple("BusDataFormat::Xml").finish(),
BusDataFormat::Rkyv => f.debug_tuple("BusDataFormat::Rkyv").finish(),
}
}
}
#[repr(u8)]
#[derive(Clone, Copy, PartialEq, Eq)]
pub enum BusEventType {
Noop,
Exit,
Call,
Result,
Fault,
Close,
}
impl core::fmt::Debug for BusEventType {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
match self {
BusEventType::Noop => f.debug_tuple("BusEventType::Noop").finish(),
BusEventType::Exit => f.debug_tuple("BusEventType::Exit").finish(),
BusEventType::Call => f.debug_tuple("BusEventType::Call").finish(),
BusEventType::Result => f.debug_tuple("BusEventType::Result").finish(),
BusEventType::Fault => f.debug_tuple("BusEventType::Fault").finish(),
BusEventType::Close => f.debug_tuple("BusEventType::Close").finish(),
}
}
}

pub type Bid = u32;
pub type Cid = u64;
#[doc = " __wasi_option_t"]
Expand Down Expand Up @@ -2389,34 +2344,6 @@ impl core::fmt::Debug for Timeout {
}
}
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct BusEvent {
pub tag: BusEventType,
pub padding: (u64, u64, u64, u64, u64, u64, u64, u32, u16, u8),
}
impl core::fmt::Debug for BusEvent {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
f.debug_struct("BusEvent")
.field("tag", &self.tag)
.field("padding", &self.padding)
.finish()
}
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct BusEvent2 {
pub tag: BusEventType,
pub event: BusEvent,
}
impl core::fmt::Debug for BusEvent2 {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
f.debug_struct("BusEvent2")
.field("tag", &self.tag)
.field("event", &self.event)
.finish()
}
}

// TODO: if necessary, must be implemented in wit-bindgen
unsafe impl ValueType for Snapshot0Clockid {
Expand Down Expand Up @@ -3068,69 +2995,6 @@ unsafe impl ValueType for Tty {
fn zero_padding_bytes(&self, _bytes: &mut [MaybeUninit<u8>]) {}
}

// TODO: if necessary, must be implemented in wit-bindgen
unsafe impl ValueType for BusDataFormat {
#[inline]
fn zero_padding_bytes(&self, _bytes: &mut [MaybeUninit<u8>]) {}
}

unsafe impl wasmer::FromToNativeWasmType for BusDataFormat {
type Native = i32;

fn to_native(self) -> Self::Native {
self as i32
}

fn from_native(n: Self::Native) -> Self {
match n {
0 => Self::Raw,
1 => Self::Bincode,
2 => Self::MessagePack,
3 => Self::Json,
4 => Self::Yaml,
5 => Self::Xml,
6 => Self::Rkyv,

q => todo!("could not serialize number {q} to enum BusDataFormat"),
}
}

fn is_from_store(&self, _store: &impl wasmer::AsStoreRef) -> bool {
false
}
}

// TODO: if necessary, must be implemented in wit-bindgen
unsafe impl ValueType for BusEventType {
#[inline]
fn zero_padding_bytes(&self, _bytes: &mut [MaybeUninit<u8>]) {}
}

unsafe impl wasmer::FromToNativeWasmType for BusEventType {
type Native = i32;

fn to_native(self) -> Self::Native {
self as i32
}

fn from_native(n: Self::Native) -> Self {
match n {
0 => Self::Noop,
1 => Self::Exit,
2 => Self::Call,
3 => Self::Result,
4 => Self::Fault,
5 => Self::Close,

q => todo!("could not serialize number {q} to enum BusEventType"),
}
}

fn is_from_store(&self, _store: &impl wasmer::AsStoreRef) -> bool {
false
}
}

// TODO: if necessary, must be implemented in wit-bindgen
unsafe impl ValueType for OptionTag {
#[inline]
Expand Down Expand Up @@ -3683,15 +3547,3 @@ unsafe impl wasmer::FromToNativeWasmType for Timeout {
false
}
}

// TODO: if necessary, must be implemented in wit-bindgen
unsafe impl ValueType for BusEvent {
#[inline]
fn zero_padding_bytes(&self, _bytes: &mut [MaybeUninit<u8>]) {}
}

// TODO: if necessary, must be implemented in wit-bindgen
unsafe impl ValueType for BusEvent2 {
#[inline]
fn zero_padding_bytes(&self, _bytes: &mut [MaybeUninit<u8>]) {}
}
6 changes: 0 additions & 6 deletions lib/wasi-types/src/wasi/bindings_manual.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,6 @@ impl From<Snapshot0SubscriptionClock> for SubscriptionClock {
}
}

impl std::fmt::Display for BusDataFormat {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{:?}", self)
}
}

impl std::fmt::Display for Sockoption {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let s = match *self {
Expand Down
Loading

0 comments on commit c98ccaf

Please sign in to comment.