Add the sync-prologue async source form

This commit is contained in:
Dennis Kobert
2026-07-27 10:47:44 +00:00
parent 470ffdab43
commit 6392c02dee
5 changed files with 244 additions and 60 deletions

View File

@@ -111,8 +111,9 @@ pub(crate) fn generate_node_code(crate_ident: &CrateIdent, parsed: &ParsedNodeFn
quote! { pub(super) #name: #r#gen }
});
let async_source = *is_async || crate::gcodegen::is_source_kernel(output_type);
let slot_value_type = crate::gcodegen::slot_value_type(output_type);
let slot_field = is_async
let slot_field = async_source
.then(|| quote! { pub(super) slot: std::sync::Arc<std::sync::Mutex<std::collections::HashMap<u64, Option<gcore::gpoll::GPoll<#slot_value_type>>>>> })
.into_iter();
let struct_fields = data_field_defs.chain(regular_field_defs).chain(slot_field);
@@ -223,11 +224,11 @@ pub(crate) fn generate_node_code(crate_ident: &CrateIdent, parsed: &ParsedNodeFn
let regular_inits = regular_field_names.iter().map(|name| {
quote! { #name }
});
let slot_init = is_async.then(|| quote! { slot: Default::default() }).into_iter();
let slot_init = async_source.then(|| quote! { slot: Default::default() }).into_iter();
let all_field_inits = data_inits.chain(regular_inits).chain(slot_init);
// Data fields may not implement Copy, PartialEq, etc., so only derive Debug and Clone
let struct_derives = if data_fields.is_empty() && !is_async {
let struct_derives = if data_fields.is_empty() && !async_source {
quote!(#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)])
} else {
quote!(#[derive(Debug, Clone)])