mirror of
https://github.com/kovidgoyal/kitty
synced 2026-06-08 22:28:24 +02:00
Speed up draining of the wakeup_fd buffer
This commit is contained in:
@@ -10,8 +10,17 @@
|
||||
#include "gl.h"
|
||||
#include "modes.h"
|
||||
|
||||
static char drain_buf[1024] = {0};
|
||||
|
||||
static PyObject*
|
||||
drain_read(PyObject UNUSED *self, PyObject *fd) {
|
||||
read(PyLong_AsLong(fd), drain_buf, sizeof(drain_buf));
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
static PyMethodDef module_methods[] = {
|
||||
GL_METHODS
|
||||
{"drain_read", (PyCFunction)drain_read, METH_O, ""},
|
||||
{"parse_bytes", (PyCFunction)parse_bytes, METH_VARARGS, ""},
|
||||
{"parse_bytes_dump", (PyCFunction)parse_bytes_dump, METH_VARARGS, ""},
|
||||
{"read_bytes", (PyCFunction)read_bytes, METH_VARARGS, ""},
|
||||
|
||||
@@ -22,7 +22,7 @@ from .constants import (
|
||||
from .fast_data_types import (
|
||||
glViewport, glBlendFunc, GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GLFW_PRESS,
|
||||
GLFW_REPEAT, GLFW_MOUSE_BUTTON_1, glfw_post_empty_event,
|
||||
GLFW_CURSOR_NORMAL, GLFW_CURSOR, GLFW_CURSOR_HIDDEN,
|
||||
GLFW_CURSOR_NORMAL, GLFW_CURSOR, GLFW_CURSOR_HIDDEN, drain_read
|
||||
)
|
||||
from .fonts import set_font_family
|
||||
from .borders import Borders, BordersProgram
|
||||
@@ -199,10 +199,7 @@ class TabManager(Thread):
|
||||
|
||||
def on_wakeup(self):
|
||||
if not self.shutting_down:
|
||||
try:
|
||||
os.read(self.read_wakeup_fd, io.DEFAULT_BUFFER_SIZE)
|
||||
except (EnvironmentError, BlockingIOError):
|
||||
pass
|
||||
drain_read(self.read_wakeup_fd)
|
||||
while True:
|
||||
try:
|
||||
func, args = self.action_queue.get_nowait()
|
||||
|
||||
Reference in New Issue
Block a user