-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Make table/memory creation async functions #11470
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -94,7 +94,8 @@ impl Table { | |
| /// # } | ||
| /// ``` | ||
| pub fn new(mut store: impl AsContextMut, ty: TableType, init: Ref) -> Result<Table> { | ||
| Table::_new(store.as_context_mut().0, ty, init) | ||
| vm::one_poll(Table::_new(store.as_context_mut().0, ty, init)) | ||
| .expect("must use `new_async` when async resource limiters are in use") | ||
|
Comment on lines
+97
to
+98
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we not assert that this is a non-async config before the
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh this is actually replicating the documented behavior where this works with |
||
| } | ||
|
|
||
| /// Async variant of [`Table::new`]. You must use this variant with | ||
|
|
@@ -111,18 +112,11 @@ impl Table { | |
| ty: TableType, | ||
| init: Ref, | ||
| ) -> Result<Table> { | ||
| let mut store = store.as_context_mut(); | ||
| assert!( | ||
| store.0.async_support(), | ||
| "cannot use `new_async` without enabling async support on the config" | ||
| ); | ||
| store | ||
| .on_fiber(|store| Table::_new(store.0, ty, init)) | ||
| .await? | ||
| Table::_new(store.as_context_mut().0, ty, init).await | ||
| } | ||
|
|
||
| fn _new(store: &mut StoreOpaque, ty: TableType, init: Ref) -> Result<Table> { | ||
| let table = generate_table_export(store, &ty)?; | ||
| async fn _new(store: &mut StoreOpaque, ty: TableType, init: Ref) -> Result<Table> { | ||
| let table = generate_table_export(store, &ty).await?; | ||
| table._fill(store, 0, init, ty.minimum())?; | ||
| Ok(table) | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And similarly assert that the config is async here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As I've been making these changes I've actually been undoing a lot of
assert!(async_support)-style assertions. Previously that was required becauseon_fiberwas immediately used which requiredasync_supportto be turned on, but now it's just normal Rust async functions so there's no reason to prevent usage whenasync_supportis disabled. In that sense it's intentional that the assert here is lost, but how's that sound to you?