Make all nodes thread safe
This commit is contained in:
@@ -2,7 +2,7 @@ use super::core::Node;
|
||||
use crate::core::registry::Registry;
|
||||
use anyhow::{ensure, Result};
|
||||
use lazy_static::lazy_static;
|
||||
use rccell::RcCell;
|
||||
use std::sync::Arc;
|
||||
|
||||
lazy_static! {
|
||||
static ref PULSE_SENDER_REGISTRY: Registry<PulseSender> = Default::default();
|
||||
@@ -11,15 +11,15 @@ lazy_static! {
|
||||
pub struct PulseSender {}
|
||||
|
||||
impl PulseSender {
|
||||
pub fn add_to(node: &RcCell<Node>) -> Result<()> {
|
||||
pub fn add_to(node: &Arc<Node>) -> Result<()> {
|
||||
ensure!(
|
||||
node.borrow().spatial.is_some(),
|
||||
node.spatial.read().is_some(),
|
||||
"Internal: Node does not have a spatial attached!"
|
||||
);
|
||||
|
||||
let sender = PulseSender {};
|
||||
let sender = PULSE_SENDER_REGISTRY.add(sender)?;
|
||||
node.borrow_mut().pulse_sender = Some(sender);
|
||||
*node.pulse_sender.write() = Some(sender);
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user