Fix build by making the registry guarded by an ArcMutex.

This commit is contained in:
Tom Alexander
2023-10-29 21:19:30 -04:00
parent f63620b547
commit 1f3b5262b8
15 changed files with 113 additions and 90 deletions

View File

@@ -7,6 +7,7 @@ use super::registry::Registry;
use super::IDocumentElement;
use super::IHeading;
use super::ISection;
use super::RefRegistry;
#[derive(Debug)]
pub(crate) struct BlogPostPage {
@@ -24,30 +25,34 @@ impl BlogPostPage {
// TODO: Move path into the registry so I can give this a standard interface like the others.
pub(crate) async fn new<'a, 'b, 'parse, P: Into<PathBuf>>(
path: P,
registry: &'a mut Registry<'b, 'parse>,
registry: RefRegistry<'b, 'parse>,
document: &'b organic::types::Document<'parse>,
) -> Result<BlogPostPage, CustomError> {
let path = path.into();
let mut children = Vec::new();
if let Some(section) = document.zeroth_section.as_ref() {
children.push(IDocumentElement::Section(
ISection::new(registry, section).await?,
ISection::new(registry.clone(), section).await?,
));
}
for heading in document.children.iter() {
children.push(IDocumentElement::Heading(
IHeading::new(registry, heading).await?,
IHeading::new(registry.clone(), heading).await?,
));
}
let footnotes = {
let footnote_definitions: Vec<_> = registry
.get_footnote_ids()
.map(|(id, def)| (id, def.clone()))
.collect();
let footnote_definitions: Vec<_> = {
let registry = registry.lock().unwrap();
let ret = registry
.get_footnote_ids()
.map(|(id, def)| (id, def.clone()))
.collect();
ret
};
let mut ret = Vec::new();
for (id, def) in footnote_definitions.into_iter() {
ret.push(IRealFootnoteDefinition::new(registry, id, def).await?);
ret.push(IRealFootnoteDefinition::new(registry.clone(), id, def).await?);
}
ret
};