Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(hydroflow_plus): split up location module and store locations directly in streams #1523

Merged
merged 1 commit into from
Nov 5, 2024

Conversation

shadaj
Copy link
Member

@shadaj shadaj commented Nov 5, 2024

No description provided.

Copy link

cloudflare-workers-and-pages bot commented Nov 5, 2024

Deploying hydroflow with  Cloudflare Pages  Cloudflare Pages

Latest commit: 486e945
Status:⚡️  Build in progress...

View logs

hydroflow_plus/src/location/cluster.rs Outdated Show resolved Hide resolved
hydroflow_plus/src/singleton.rs Show resolved Hide resolved
@@ -134,24 +137,24 @@ impl<'a, T, N: Location<'a>> DeferTick for Singleton<T, Bounded, Tick<N>> {

impl<'a, T, N: Location<'a>> CycleComplete<'a, TickCycle> for Singleton<T, Bounded, Tick<N>> {
fn complete(self, ident: syn::Ident) {
self.flow_state.borrow_mut().leaves.as_mut().expect("Attempted to add a leaf to a flow that has already been finalized. No leaves can be added after the flow has been compiled.").push(HfPlusLeaf::CycleSink {
self.flow_state().clone().borrow_mut().leaves.as_mut().expect("Attempted to add a leaf to a flow that has already been finalized. No leaves can be added after the flow has been compiled.").push(HfPlusLeaf::CycleSink {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the clone? Rc will just increment then immediately decrement?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Borrow checker is unhappy if we don't clone because self is borrowed by .flow_state() but we need to move the IR node.

Comment on lines +140 to 143
self.flow_state().clone().borrow_mut().leaves.as_mut().expect("Attempted to add a leaf to a flow that has already been finalized. No leaves can be added after the flow has been compiled.").push(HfPlusLeaf::CycleSink {
ident,
location_kind: self.location_kind,
location_kind: self.location_kind(),
input: Box::new(self.ir_node.into_inner()),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could avoid the clone via

input: Box::new(self.ir_node.replace(HfPlusNode::Placeholder)),

(or implement Default for HfPlusNode -> Placeholder and use self.ir_node.take())

Doesn't really matter that much though

@shadaj shadaj merged commit d9634f2 into main Nov 5, 2024
24 of 25 checks passed
@shadaj shadaj deleted the pr1523 branch November 5, 2024 18:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants