Skip to content

Commit

Permalink
Merge pull request #33 from iMplode-nZ/main
Browse files Browse the repository at this point in the history
Fix `Shared` double-entering mutex and causing crash.
  • Loading branch information
shiinamiyuki authored Mar 15, 2024
2 parents 6838dc5 + 51d1ff8 commit 92cfa27
Showing 1 changed file with 17 additions and 16 deletions.
33 changes: 17 additions & 16 deletions luisa_compute/src/lang/types/shared.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,25 @@ pub struct Shared<T: Value> {
}
impl<T: Value> Shared<T> {
pub fn new(length: usize) -> Self {
let shared = with_recorder(|r| {
let shared = new_node(
&r.pools,
Node::new(
CArc::new(Instruction::Shared),
ir::context::register_type(Type::Array(ArrayType {
element: T::type_(),
length,
})),
),
)
.into();

r.shared.push(shared);
shared
});
Self {
marker: PhantomData,
node: with_recorder(|r| {
let shared = new_node(
&r.pools,
Node::new(
CArc::new(Instruction::Shared),
ir::context::register_type(Type::Array(ArrayType {
element: T::type_(),
length,
})),
),
)
.into();

r.shared.push(shared);
shared.into()
}),
node: shared.into(),
}
}
pub fn len_expr(&self) -> Expr<u64> {
Expand Down

0 comments on commit 92cfa27

Please sign in to comment.