Skip to content

Commit

Permalink
Update naming
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreiEres committed Jun 4, 2024
1 parent 4b155f7 commit e0b1975
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 22 deletions.
4 changes: 2 additions & 2 deletions orchestra/proc-macro/src/impl_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ pub(crate) fn impl_feature_gated_items(
let channel_name_rx = &cfg_set.channel_names_without_wip("_rx");
let channel_name_unbounded_rx = &info.channel_names_without_wip("_unbounded_rx");

let with_priority_channel = &cfg_set.with_priority_channel_without_wip();
let can_receive_priority_messages = &cfg_set.can_receive_priority_messages_without_wip();

let baggage_name = &info.baggage_names();
let baggage_generic_ty = &info.baggage_generic_types();
Expand Down Expand Up @@ -635,7 +635,7 @@ pub(crate) fn impl_feature_gated_items(
>();

#(
let (#channel_name_tx, #channel_name_rx) = if #with_priority_channel {
let (#channel_name_tx, #channel_name_rx) = if #can_receive_priority_messages {
#support_crate ::metered::channel_with_priority::<
MessagePacket< #maybe_boxed_consumes >
>(
Expand Down
39 changes: 20 additions & 19 deletions orchestra/proc-macro/src/parse/parse_orchestra_struct.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ mod kw {
syn::custom_keyword!(sends);
syn::custom_keyword!(message_capacity);
syn::custom_keyword!(signal_capacity);
syn::custom_keyword!(with_priority_channel);
syn::custom_keyword!(can_receive_priority_messages);
}

#[derive(Clone, Debug)]
Expand All @@ -59,8 +59,8 @@ pub(crate) enum SubSysAttrItem {
MessageChannelCapacity(ChannelCapacity<kw::message_capacity>),
/// Custom signal channels capacity for this subsystem
SignalChannelCapacity(ChannelCapacity<kw::signal_capacity>),
/// The subsystem can send priority messages
WithPriorityChannel(kw::with_priority_channel),
/// The subsystem can receive priority messages
CanReceivePriorityMessages(kw::can_receive_priority_messages),
}

impl Parse for SubSysAttrItem {
Expand All @@ -76,8 +76,8 @@ impl Parse for SubSysAttrItem {
Self::MessageChannelCapacity(input.parse::<ChannelCapacity<kw::message_capacity>>()?)
} else if lookahead.peek(kw::signal_capacity) {
Self::SignalChannelCapacity(input.parse::<ChannelCapacity<kw::signal_capacity>>()?)
} else if lookahead.peek(kw::with_priority_channel) {
Self::WithPriorityChannel(input.parse::<kw::with_priority_channel>()?)
} else if lookahead.peek(kw::can_receive_priority_messages) {
Self::CanReceivePriorityMessages(input.parse::<kw::can_receive_priority_messages>()?)
} else {
Self::Consumes(input.parse::<Consumes>()?)
})
Expand Down Expand Up @@ -105,8 +105,8 @@ impl ToTokens for SubSysAttrItem {
Self::SignalChannelCapacity(_) => {
quote! {}
},
Self::WithPriorityChannel(with_priority_channel) => {
quote! { #with_priority_channel }
Self::CanReceivePriorityMessages(can_receive_priority_messages) => {
quote! { #can_receive_priority_messages }
},
};
tokens.extend(ts.into_iter());
Expand Down Expand Up @@ -138,8 +138,8 @@ pub(crate) struct SubSysField {
pub(crate) message_capacity: Option<usize>,
/// Custom signal channel capacity
pub(crate) signal_capacity: Option<usize>,
/// The subsystem can send priority messages
pub(crate) with_priority_channel: bool,
/// The subsystem can receive priority messages
pub(crate) can_receive_priority_messages: bool,

pub(crate) feature_gates: Option<CfgPredicate>,
}
Expand Down Expand Up @@ -362,8 +362,8 @@ pub(crate) struct SubSystemAttrItems {
pub(crate) message_capacity: Option<ChannelCapacity<kw::message_capacity>>,
/// Custom signal channel capacity
pub(crate) signal_capacity: Option<ChannelCapacity<kw::signal_capacity>>,
/// The subsystem can send priority messages
pub(crate) with_priority_channel: bool,
/// The subsystem can receive priority messages
pub(crate) can_receive_priority_messages: bool,
}

impl Parse for SubSystemAttrItems {
Expand Down Expand Up @@ -405,7 +405,8 @@ impl Parse for SubSystemAttrItems {
let wip = extract_variant!(unique, Wip; default = false);
let message_capacity = extract_variant!(unique, MessageChannelCapacity take );
let signal_capacity = extract_variant!(unique, SignalChannelCapacity take );
let with_priority_channel = extract_variant!(unique, WithPriorityChannel; default = false);
let can_receive_priority_messages =
extract_variant!(unique, CanReceivePriorityMessages; default = false);

Ok(Self {
blocking,
Expand All @@ -414,7 +415,7 @@ impl Parse for SubSystemAttrItems {
consumes,
message_capacity,
signal_capacity,
with_priority_channel,
can_receive_priority_messages,
})
}
}
Expand Down Expand Up @@ -509,8 +510,8 @@ impl<'a> SubsystemConfigSet<'a> {
signal_channel_capacities_without_wip(&self.enabled_subsystems, default_capacity)
}

pub(crate) fn with_priority_channel_without_wip(&self) -> Vec<TokenStream> {
with_priority_channel_without_wip(&self.enabled_subsystems)
pub(crate) fn can_receive_priority_messages_without_wip(&self) -> Vec<TokenStream> {
can_receive_priority_messages_without_wip(&self.enabled_subsystems)
}
}

Expand Down Expand Up @@ -763,7 +764,7 @@ impl OrchestraGuts {
sends,
message_capacity,
signal_capacity,
with_priority_channel,
can_receive_priority_messages,
..
} = subsystem_attrs;

Expand All @@ -787,7 +788,7 @@ impl OrchestraGuts {
message_capacity,
signal_capacity,
feature_gates,
with_priority_channel,
can_receive_priority_messages,
});
} else {
// collect the "baggage"
Expand Down Expand Up @@ -921,12 +922,12 @@ pub(crate) fn consumes_without_wip<'a, T: Borrow<SubSysField>>(subsystems: &[T])
.collect::<Vec<_>>()
}

pub(crate) fn with_priority_channel_without_wip(
pub(crate) fn can_receive_priority_messages_without_wip(
subsystems: &Vec<&SubSysField>,
) -> Vec<TokenStream> {
subsystems
.iter()
.filter(|ssf| !ssf.wip)
.map(|ssf| if ssf.with_priority_channel { quote!(true) } else { quote!(false) })
.map(|ssf| if ssf.can_receive_priority_messages { quote!(true) } else { quote!(false) })
.collect::<Vec<_>>()
}
2 changes: 1 addition & 1 deletion orchestra/tests/subsystem_with_priority_channel_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ pub struct Orchestra {
#[subsystem(consumes: MsgA, sends: [MsgB])]
sub_a: SubA,

#[subsystem(consumes: MsgB, sends: [MsgA], with_priority_channel)]
#[subsystem(consumes: MsgB, sends: [MsgA], can_receive_priority_messages)]
sub_b: SubB,
}

Expand Down

0 comments on commit e0b1975

Please sign in to comment.