Skip to content

Commit

Permalink
Pinned Channels (#2811)
Browse files Browse the repository at this point in the history
* Switch to pinned channels.

* Fix ServerRenderer so it's not blocked until the result is resolved.

* Fix tests.

* Remove unused SendError.

* Revert channel-based BufWriter.

* Removed unused fmt module.

* Update docs.

* Add safety comments, adjust borrowing designs.

* Adjust oneshot as well.

* Fix workflow temporarily.

* Cell or UnsafeCell?

* Update safety notice.

* Should be sync.

* Actually should be both.

* Update packages/yew/src/platform/pinned/mpsc.rs

Co-authored-by: Muhammad Hamza <muhammadhamza1311@gmail.com>

Co-authored-by: Muhammad Hamza <muhammadhamza1311@gmail.com>
  • Loading branch information
futursolo and hamza1311 committed Aug 16, 2022
1 parent 11fde63 commit 5079885
Show file tree
Hide file tree
Showing 7 changed files with 628 additions and 4 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/main-checks.yml
Expand Up @@ -184,7 +184,7 @@ jobs:
env:
# workaround for lack of ternary operator
# see https://github.com/orgs/community/discussions/25725
RUSTFLAGS: ${{ matrix.toolchain == 'nightly && '--cfg nightly_yew' || '' }}
RUSTFLAGS: ${{ matrix.toolchain == 'nightly' && '--cfg nightly_yew' || '' }}
with:
command: test
args: --all-targets --workspace --exclude yew
Expand All @@ -194,7 +194,7 @@ jobs:
env:
# workaround for lack of ternary operator
# see https://github.com/orgs/community/discussions/25725
RUSTFLAGS: ${{ matrix.toolchain == 'nightly && '--cfg nightly_yew' || '' }}
RUSTFLAGS: ${{ matrix.toolchain == 'nightly' && '--cfg nightly_yew' || '' }}
with:
command: test
args: -p yew --all-features
Expand Down
2 changes: 1 addition & 1 deletion packages/yew/src/html/component/lifecycle.rs
Expand Up @@ -40,7 +40,7 @@ pub(crate) enum ComponentRenderState {
},
#[cfg(feature = "ssr")]
Ssr {
sender: Option<crate::platform::sync::oneshot::Sender<Html>>,
sender: Option<crate::platform::pinned::oneshot::Sender<Html>>,
},
}

Expand Down
2 changes: 1 addition & 1 deletion packages/yew/src/html/component/scope.rs
Expand Up @@ -265,7 +265,7 @@ mod feat_ssr {
ComponentRenderState, CreateRunner, DestroyRunner, RenderRunner,
};
use crate::platform::io::BufWriter;
use crate::platform::sync::oneshot;
use crate::platform::pinned::oneshot;
use crate::scheduler;
use crate::virtual_dom::Collectable;

Expand Down
1 change: 1 addition & 0 deletions packages/yew/src/platform/mod.rs
Expand Up @@ -45,6 +45,7 @@ use std::future::Future;
#[cfg(feature = "ssr")]
pub(crate) mod io;

pub mod pinned;
pub mod sync;
pub mod time;

Expand Down
6 changes: 6 additions & 0 deletions packages/yew/src/platform/pinned/mod.rs
@@ -0,0 +1,6 @@
//! Task synchronisation primitives for pinned tasks.
//!
//! This module provides task synchronisation for `!Send` futures.

pub mod mpsc;
pub mod oneshot;

0 comments on commit 5079885

Please sign in to comment.