mirror of
https://github.com/Zenithsiz/dynatos.git
synced 2026-02-03 18:13:04 +00:00
Split effect::running into running and running_in.
This commit is contained in:
parent
c9069cc819
commit
bf75ad6069
@ -10,7 +10,11 @@
|
||||
#[cfg(debug_assertions)]
|
||||
use core::panic::Location;
|
||||
use {
|
||||
crate::{world::EffectStack, ReactiveWorld, WeakTrigger},
|
||||
crate::{
|
||||
world::{EffectStack, ReactiveWorldInner},
|
||||
ReactiveWorld,
|
||||
WeakTrigger,
|
||||
},
|
||||
core::{
|
||||
fmt,
|
||||
hash::Hash,
|
||||
@ -419,7 +423,13 @@ impl<W: ReactiveWorld> Drop for EffectDepsGatherer<'_, W> {
|
||||
|
||||
/// Returns the current running effect
|
||||
#[must_use]
|
||||
pub fn running<W: ReactiveWorld>() -> Option<Effect<W::F, W>> {
|
||||
pub fn running() -> Option<Effect<<WorldDefault as ReactiveWorldInner>::F>> {
|
||||
self::running_in::<WorldDefault>()
|
||||
}
|
||||
|
||||
/// Returns the current running effect in a world
|
||||
#[must_use]
|
||||
pub fn running_in<W: ReactiveWorld>() -> Option<Effect<W::F, W>> {
|
||||
<W>::EffectStack::top()
|
||||
}
|
||||
|
||||
@ -530,7 +540,7 @@ mod test {
|
||||
fn get_running_100_none(bencher: &mut Bencher) {
|
||||
bencher.iter(|| {
|
||||
for _ in 0..100 {
|
||||
let effect = effect::running::<WorldDefault>();
|
||||
let effect = effect::running();
|
||||
test::black_box(effect);
|
||||
}
|
||||
});
|
||||
@ -543,7 +553,7 @@ mod test {
|
||||
effect.gather_dependencies(|| {
|
||||
bencher.iter(|| {
|
||||
for _ in 0..100 {
|
||||
let effect = effect::running::<WorldDefault>();
|
||||
let effect = effect::running();
|
||||
test::black_box(effect);
|
||||
}
|
||||
});
|
||||
|
||||
@ -40,7 +40,7 @@ impl<'a, S, W: ReactiveWorld> EnumSplitValueUpdateCtx<'a, S, W> {
|
||||
{
|
||||
let signal = Signal::new(value);
|
||||
|
||||
let cur_effect = effect::running::<W>().expect("Missing running effect");
|
||||
let cur_effect = effect::running_in::<W>().expect("Missing running effect");
|
||||
|
||||
// Create the write-back effect.
|
||||
// Note: We don't want to run it and write into the outer at startup, so
|
||||
|
||||
@ -177,7 +177,7 @@ impl<W: ReactiveWorld> Trigger<W> {
|
||||
// TODO: Should we remove all existing subscribers before gathering them?
|
||||
#[track_caller]
|
||||
pub fn gather_subscribers(&self) {
|
||||
match effect::running::<W>() {
|
||||
match effect::running_in::<W>() {
|
||||
Some(effect) => {
|
||||
effect.add_dependency(self.downgrade());
|
||||
self.add_subscriber(effect);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user