Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1116,14 +1116,21 @@ pub struct FutureReader<T> {

impl<T> FutureReader<T> {
/// Create a new future with the specified producer.
///
/// # Panics
///
/// Panics if component-model-async is not enabled in this store's config.
pub fn new<S: AsContextMut>(
mut store: S,
producer: impl FutureProducer<S::Data, Item = T>,
) -> Self
where
T: func::Lower + func::Lift + Send + Sync + 'static,
{
assert!(store.as_context().0.cm_concurrency_enabled());
assert!(
store.as_context().0.cm_concurrency_enabled(),
"cannot use `FutureReader::new` when component-model-async is not enabled on the config"
);

struct Producer<P>(P);

Expand Down Expand Up @@ -1451,11 +1458,16 @@ where
A: AsAccessor,
{
/// Create a new `GuardedFutureReader` with the specified `accessor` and `reader`.
///
/// # Panics
///
/// Panics if component-model-async is not enabled in this store's config.
pub fn new(accessor: A, reader: FutureReader<T>) -> Self {
assert!(
accessor
.as_accessor()
.with(|a| a.as_context().0.cm_concurrency_enabled())
.with(|a| a.as_context().0.cm_concurrency_enabled()),
"cannot use `GuardedFutureReader` when component-model-async is not enabled on the config"
);
Self {
reader: Some(reader),
Expand Down Expand Up @@ -1503,14 +1515,21 @@ pub struct StreamReader<T> {

impl<T> StreamReader<T> {
/// Create a new stream with the specified producer.
///
/// # Panics
///
/// Panics if component-model-async is not enabled in this store's config.
pub fn new<S: AsContextMut>(
mut store: S,
producer: impl StreamProducer<S::Data, Item = T>,
) -> Self
where
T: func::Lower + func::Lift + Send + Sync + 'static,
{
assert!(store.as_context().0.cm_concurrency_enabled());
assert!(
store.as_context().0.cm_concurrency_enabled(),
"cannot use `StreamReader` when component-model-async is not enabled on the config"
);
Self::new_(
store
.as_context_mut()
Expand Down Expand Up @@ -1785,11 +1804,16 @@ where
{
/// Create a new `GuardedStreamReader` with the specified `accessor` and
/// `reader`.
///
/// # Panics
///
/// Panics if component-model-async is not enabled in this store's config.
pub fn new(accessor: A, reader: StreamReader<T>) -> Self {
assert!(
accessor
.as_accessor()
.with(|a| a.as_context().0.cm_concurrency_enabled())
.with(|a| a.as_context().0.cm_concurrency_enabled()),
"cannot use `GuardedStreamReader` when component-model-async is not enabled on the config"
);
Self {
reader: Some(reader),
Expand Down
7 changes: 6 additions & 1 deletion crates/wasmtime/src/runtime/component/func/typed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,8 @@ where
/// Panics if the store that the [`Accessor`] is derived from does not own
/// this function.
///
/// Panics if component-model-async is not enabled in this store's config.
///
/// # Example
///
/// Using [`StoreContextMut::run_concurrent`] to get an [`Accessor`]:
Expand Down Expand Up @@ -320,7 +322,10 @@ where
{
let result = accessor.as_accessor().with(|mut store| {
let mut store = store.as_context_mut();
assert!(store.0.cm_concurrency_enabled());
assert!(
store.0.cm_concurrency_enabled(),
"cannot use `call_concurrent` when component-model-async is not enabled on the config"
);
assert!(
store.0.async_support(),
"cannot use `call_concurrent` when async support is not enabled on the config"
Expand Down