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

Creating a version of fyne.Do that does not wait #5448

Merged
merged 5 commits into from
Jan 23, 2025

Conversation

andydotxyz
Copy link
Member

Naming and implementation open for discussion

Checklist:

  • Tests included.
  • Lint and formatter run with no errors.
  • Tests all pass.
  • Public APIs match existing style and have Since: line.

@Jacalz
Copy link
Member

Jacalz commented Jan 21, 2025

I will review this further tomorrow but this does look great. The name is want I was going to suggest actually :)

@@ -407,7 +407,7 @@ func (c *canvas) waitForDoubleTap(co fyne.CanvasObject, ev *fyne.PointEvent, tap
c.touchCancelFunc = nil
c.touchLastTapped = nil
c.touchCancelLock.Unlock()
})
}, true)
Copy link
Contributor

Choose a reason for hiding this comment

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

should this function call just be converted to fyne.DoAsync?

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm not sure - that is going out of the driver to a utility function which does thread checks then back into the driver code - feels inefficient. Either way wouldn't it be the Sync/wait/fyne.Do version?

@andydotxyz
Copy link
Member Author

I am wondering about naming - and defaults..

Should we change so fyne.Do, fyne.DoAsync = fyne.Wait, fyne.Do?

Although our driver code will more often than not want to wait (though even the async version maintains order of operations queued...) but for app developers won't the async version be more common? i.e. "I updated a value, now go refresh"...

@Jacalz
Copy link
Member

Jacalz commented Jan 22, 2025

Hmm. I think you are right. That does seem like a good change, though I hink I'd prefer fyne.WaitFor() over fyne.Wait() as it sounds more like you are waiting on what you passed in to be finished.

@Jacalz Jacalz changed the title Creating a version of that does not wait Creating a version of fyne.Do that does not wait Jan 22, 2025
@dweymouth
Copy link
Contributor

I don't like fyne.Wait on its own, but fyne.DoWait could be OK. I think having the "Do" verb in common for both names is important for clarity.

Copy link
Member

@Jacalz Jacalz left a comment

Choose a reason for hiding this comment

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

I´d personally prefer WaitFor given that DoWait and Wait seems to have the same logical meaning, at least to me, in the case of new names. Otherwise I'm really happy with this change. Nice catch with the more efficient thread scheduling.

@andydotxyz
Copy link
Member Author

What about "DoAndWait" or "DoBlock"?

@Jacalz
Copy link
Member

Jacalz commented Jan 22, 2025

I'm a bit sceptical, sorry. I don't know what it is about it but having "block" in the name seems strange also sounds ass we are doing a block of something. I think what is in this PR is better in that case. One option is to just make fyne.Do() take a wait parameter?

@dweymouth
Copy link
Contributor

dweymouth commented Jan 22, 2025

The only naming thing I think is important is that the 2 are connected somehow, eg through a common verb like "Do", or through the wait bool param that @Jacalz suggested. I think whatever we settle on, it should be obvious just from the API naming that they are connected.

I wonder if, despite the verbosity in the common case, Do/DoAsync is the best name, though DoAndWait, or even DoWait, seems fine to me

@andydotxyz
Copy link
Member Author

It seems like DoAndWait may satisfy all the comments above but I will sleep on it :).

@Jacalz
Copy link
Member

Jacalz commented Jan 23, 2025

I'm not 100% sold on DoAndWait but it isn't terrible so I don't wish to hold this up :)

@andydotxyz andydotxyz merged commit 9afc137 into fyne-io:develop Jan 23, 2025
12 checks passed
@andydotxyz andydotxyz deleted the feature/fynedoasync branch January 23, 2025 21:42
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.

3 participants