require Send for S for resolve_passes multithreaded
This commit is contained in:
1 parent
c1fc00ed53
commit
2d67dabfe5
3 files changed
+13
-15
No files matched your search
@@ -310,11 +310,7 @@ impl<T> AnyPass<T> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct RawPointer<T>(*mut T);
|
pub fn resolve_passes<T, Tr: TreeView<T> + Sync + Send>(
|
||||||
unsafe impl<T> Send for RawPointer<T> {}
|
|
||||||
unsafe impl<T> Sync for RawPointer<T> {}
|
|
||||||
|
|
||||||
pub fn resolve_passes<T, Tr: TreeView<T> + Sync>(
|
|
||||||
tree: &mut Tr,
|
tree: &mut Tr,
|
||||||
dirty_nodes: DirtyNodeStates,
|
dirty_nodes: DirtyNodeStates,
|
||||||
mut passes: Vec<&AnyPass<T>>,
|
mut passes: Vec<&AnyPass<T>>,
|
||||||
@@ -342,19 +338,21 @@ pub fn resolve_passes<T, Tr: TreeView<T> + Sync>(
|
|||||||
let pass = passes.remove(i);
|
let pass = passes.remove(i);
|
||||||
resolving.push(pass_id);
|
resolving.push(pass_id);
|
||||||
currently_borrowed |= pass_mask;
|
currently_borrowed |= pass_mask;
|
||||||
let tree_mut = tree as *mut _;
|
let tree_mut_unbounded = unsafe { &mut *(tree as *mut _ as *mut Tr) };
|
||||||
let raw_ptr = RawPointer(tree_mut);
|
|
||||||
let dirty_states = dirty_states.clone();
|
let dirty_states = dirty_states.clone();
|
||||||
let nodes_updated = nodes_updated.clone();
|
let nodes_updated = nodes_updated.clone();
|
||||||
let ctx = ctx.clone();
|
let ctx = ctx.clone();
|
||||||
s.spawn(move || unsafe {
|
s.spawn(move || {
|
||||||
// let tree_mut: &mut Tr = &mut *raw_ptr.0;
|
|
||||||
let raw = raw_ptr;
|
|
||||||
// this is safe because the member_mask acts as a per-member mutex and we have verified that the pass does not overlap with any other pass
|
// this is safe because the member_mask acts as a per-member mutex and we have verified that the pass does not overlap with any other pass
|
||||||
let tree_mut: &mut Tr = &mut *raw.0;
|
|
||||||
let mut dirty = DirtyNodes::default();
|
let mut dirty = DirtyNodes::default();
|
||||||
dirty_states.all_dirty(pass_id, &mut dirty, tree_mut);
|
dirty_states.all_dirty(pass_id, &mut dirty, tree_mut_unbounded);
|
||||||
pass.resolve(tree_mut, dirty, &dirty_states, &nodes_updated, &ctx);
|
pass.resolve(
|
||||||
|
tree_mut_unbounded,
|
||||||
|
dirty,
|
||||||
|
&dirty_states,
|
||||||
|
&nodes_updated,
|
||||||
|
&ctx,
|
||||||
|
);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
i += 1;
|
i += 1;
|
||||||
|
|||||||
@@ -398,7 +398,7 @@ impl<S: State> RealDom<S> {
|
|||||||
|
|
||||||
impl<S: State + Sync> RealDom<S>
|
impl<S: State + Sync> RealDom<S>
|
||||||
where
|
where
|
||||||
Tree<Node<S>>: Sync,
|
Tree<Node<S>>: Sync + Send,
|
||||||
{
|
{
|
||||||
/// Update the state of the dom, after appling some mutations. This will keep the nodes in the dom up to date with their VNode counterparts.
|
/// Update the state of the dom, after appling some mutations. This will keep the nodes in the dom up to date with their VNode counterparts.
|
||||||
/// This will resolve the state in parallel
|
/// This will resolve the state in parallel
|
||||||
|
|||||||
@@ -217,7 +217,7 @@ pub trait State: Default + Clone + 'static {
|
|||||||
const MASKS: &'static [NodeMask];
|
const MASKS: &'static [NodeMask];
|
||||||
|
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
fn update<T: TreeView<Node<Self>> + Sync>(
|
fn update<T: TreeView<Node<Self>> + Sync + Send>(
|
||||||
dirty: DirtyNodeStates,
|
dirty: DirtyNodeStates,
|
||||||
tree: &mut T,
|
tree: &mut T,
|
||||||
ctx: SendAnyMap,
|
ctx: SendAnyMap,
|
||||||
|
|||||||
Reference in new issue
Block a user