mirror of
https://github.com/rivo/tview.git
synced 2026-04-26 21:35:54 +03:00
[GH-ISSUE #199] Using app.SetInputCapture() to call app.QueueUpdate() could cause deadlock #154
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/tview#154
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 @3cb on GitHub (Dec 4, 2018).
Original GitHub issue: https://github.com/rivo/tview/issues/199
If
Application.QueueUpdate()is called usingApplication.SetInputCapture()the main event loop will deadlock if the updates channel buffer is already full. The following example replicates this. If you hit Ctrl-Q it will freeze:@rivo commented on GitHub (Dec 14, 2018):
I see. Well, the invocation of the
SetInputCapture()callback is already part of the main event loop. CallingQueueUpdateDraw()is not required here. In fact, as you demonstrated, it may even lead to a deadlock. It's kind of already described in the package documentation:I'll add some more clarification there but I don't think this requires any changes in the code. (Besides, I wouldn't even know how to avoid such a deadlock.)
@ricochet1k commented on GitHub (Dec 14, 2018):
To avoid the deadlock you can check if you are already running in the main loop and just run the update instead of queueing it.
@rivo commented on GitHub (Dec 15, 2018):
Yeah, I guess I could. I'd like to avoid having people call
QueueUpdateDraw()everywhere, though. It's meant to help you avoid race conditions in some situations. Most programs will not require it. So unless I'm getting lots of issues here where people have trouble understanding the distinction, I'll leave it the way it is. (And if they have trouble understanding it, there may be a different problem to solve.)