Enable timers for the UI thread as well

This commit is contained in:
Kovid Goyal
2016-12-01 08:31:35 +05:30
parent fbb787e850
commit 7f7d826365
2 changed files with 17 additions and 11 deletions

View File

@@ -61,6 +61,20 @@ def clear_buffers(window, opts):
glfw_swap_interval(1)
def dispatch_pending_calls(tabs):
while True:
try:
func, args = tabs.pending_ui_thread_calls.get_nowait()
except Empty:
break
try:
func(*args)
except Exception:
import traceback
traceback.print_exc()
tabs.ui_timers()
def run_app(opts, args):
setup_opengl()
window = Window(
@@ -75,17 +89,8 @@ def run_app(opts, args):
while not window.should_close():
tabs.render()
window.swap_buffers()
glfw_wait_events()
while True:
try:
func, args = tabs.pending_ui_thread_calls.get_nowait()
except Empty:
break
try:
func(*args)
except Exception:
import traceback
traceback.print_exc()
glfw_wait_events(tabs.ui_timers.timeout())
dispatch_pending_calls(tabs)
finally:
tabs.destroy()
del window

View File

@@ -113,6 +113,7 @@ class TabManager(Thread):
self.read_dispatch_map = {self.signal_fd: self.signal_received, self.read_wakeup_fd: self.on_wakeup}
self.all_writers = []
self.timers = Timers()
self.ui_timers = Timers()
self.pending_ui_thread_calls = Queue()
self.write_dispatch_map = {}
set_tab_manager(self)