mirror of
https://github.com/rivo/tview.git
synced 2026-04-26 21:35:54 +03:00
[GH-ISSUE #534] Non-blocking Queue... commands? #390
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/tview#390
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @normen on GitHub (Nov 28, 2020).
Original GitHub issue: https://github.com/rivo/tview/issues/534
Hey,
first of all thanks for this library, it's a joy to create apps with it.
That said, I was a bit confused about the
QueueUpdate(Draw)calls as they seem to be actually blocking until the supplied function returns. From other similar application designs (e.g. Javas swing EventQueue) I was expecting the call to return immediately and only execute the func separately when the next draw update is happening in the app.Obviously doing it in the way you did has its own merits but my apps design kind of expects the "usual" update queue, so I have to basically do
go func(){app.QueueUpdate(func(){WhatIWantToDo}}which seems kind of backwards.So the question is if theres any better way to actually queue the call asynchronously or if theres any plans to add such features.
Cheers,
Normen
@rivo commented on GitHub (Dec 4, 2020):
I'm not sure why you're wrapping the call in another function. I would expect the following to work:
That's just three extra characters ("
go") than not running it as a goroutine. And because of the ease of doing this, I opted for this implementation because it would be a lot more overhead to introduce another mechanism that would tell you that your function has finished (in case you need that information).Does this answer your question?
@normen commented on GitHub (Dec 4, 2020):
Right, thats unnecessary. I don't have much experience with go, if you say that starting go routines for each line of text I add to a text view or each entry I add to a list is fine then I'll believe you :)
@rivo commented on GitHub (Dec 4, 2020):
You can't make a goroutine out of everything without running into problems. It should work for this case. For everything else, please check out the following page: https://github.com/rivo/tview/wiki/Concurrency
It also talks about adding text to a
TextView. In a nutshell, callingQueueUpdate()is not necessary for that.@normen commented on GitHub (Dec 4, 2020):
Yes, I saw that, its very convenient. Okay so my instinct was somewhat right but it should be okay for this use case.. Well I'll keep that in mind and try combining stuff in one call. Thanks!