diff --git a/include/rofi-types.h b/include/rofi-types.h index 4fc878d4a..4fdb3e37b 100644 --- a/include/rofi-types.h +++ b/include/rofi-types.h @@ -370,6 +370,7 @@ typedef struct rofi_int_matcher_t { */ typedef struct _thread_state { void (*callback)(struct _thread_state *t, gpointer data); + int priority; } thread_state; extern GThreadPool *tpool; diff --git a/source/rofi-icon-fetcher.c b/source/rofi-icon-fetcher.c index c65463aee..c2bb0f1f4 100644 --- a/source/rofi-icon-fetcher.c +++ b/source/rofi-icon-fetcher.c @@ -411,6 +411,7 @@ uint32_t rofi_icon_fetcher_query_advanced(const char *name, const int wsize, // Push into fetching queue. sentry->state.callback = rofi_icon_fetcher_worker; + sentry->state.priority = G_PRIORITY_LOW; g_thread_pool_push(tpool, sentry, NULL); return sentry->uid; @@ -447,6 +448,7 @@ uint32_t rofi_icon_fetcher_query(const char *name, const int size) { // Push into fetching queue. sentry->state.callback = rofi_icon_fetcher_worker; + sentry->state.priority = G_PRIORITY_LOW; g_thread_pool_push(tpool, sentry, NULL); return sentry->uid; diff --git a/source/view.c b/source/view.c index 4b32cb8e9..29ca23073 100644 --- a/source/view.c +++ b/source/view.c @@ -1444,6 +1444,7 @@ static gboolean rofi_view_refilter_real(RofiViewState *state) { states[i].plen = plen; states[i].pattern = pattern; states[i].st.callback = filter_elements; + states[i].st.priority = G_PRIORITY_HIGH; if (i > 0) { g_thread_pool_push(tpool, &states[i], NULL); } @@ -2624,6 +2625,15 @@ void rofi_view_cleanup() { input_history_save(); } + +static int rofi_thread_workers_sort(gconstpointer a,gconstpointer b, gpointer data G_GNUC_UNUSED) +{ + thread_state *tsa = (thread_state *)a; + thread_state *tsb = (thread_state *)b; + // lower number is lower priority.. a is sorted above is a > b. + return tsa->priority-tsb->priority; +} + void rofi_view_workers_initialize(void) { TICK_N("Setup Threadpool, start"); if (config.threads == 0) { @@ -2649,6 +2659,7 @@ void rofi_view_workers_initialize(void) { g_error_free(error); exit(EXIT_FAILURE); } + g_thread_pool_set_sort_function(tpool, rofi_thread_workers_sort, NULL); TICK_N("Setup Threadpool, done"); } void rofi_view_workers_finalize(void) {