[GH-ISSUE #534] Non-blocking Queue... commands? #390

Closed
opened 2026-03-04 01:04:34 +03:00 by kerem · 4 comments
Owner

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

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
kerem closed this issue 2026-03-04 01:04:34 +03:00
Author
Owner

@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:

go app.QueueUpdate(func() { ... })

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?

<!-- gh-comment-id:738844815 --> @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: ```go go app.QueueUpdate(func() { ... }) ``` 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?
Author
Owner

@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 :)

<!-- gh-comment-id:738866471 --> @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 :)
Author
Owner

@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, calling QueueUpdate() is not necessary for that.

<!-- gh-comment-id:738892064 --> @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, calling `QueueUpdate()` is not necessary for that.
Author
Owner

@normen commented on GitHub (Dec 4, 2020):

It also talks about adding text to a TextView. In a nutshell, calling QueueUpdate() is not necessary for that.

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!

<!-- gh-comment-id:738908008 --> @normen commented on GitHub (Dec 4, 2020): > It also talks about adding text to a `TextView`. In a nutshell, calling `QueueUpdate()` is not necessary for that. 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!
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/tview#390
No description provided.