all: change scheduling priority for idle actions to G_PRIORITY_DEFAULT_IDLE

g_idle_add() uses G_PRIORITY_DEFAULT_IDLE priority. Most of the time we don't
care much about the priority.

But at the places that this patch changes, I think that using
G_PRIORITY_DEFAULT_IDLE (and following g_idle_add()) is more correct. The
reason for this is not very strong, except that it's probably the better
choice. And the old choice was made because I didn't realize that
g_idle_add() uses another default priority. Hence, the old choice was not
for good reasons either.
This commit is contained in:
Thomas Haller 2022-03-08 14:29:51 +01:00
parent 15e8837945
commit 9b030a3988
No known key found for this signature in database
GPG key ID: 29C2366E4DFC5728
4 changed files with 19 additions and 8 deletions

View file

@ -921,8 +921,10 @@ _ipv4ll_state_change_on_idle(NML3IPv4LL *self)
nm_assert(NM_IS_L3_IPV4LL(self));
if (!self->state_change_on_idle_source) {
self->state_change_on_idle_source =
nm_g_idle_source_new(G_PRIORITY_DEFAULT, _ipv4ll_state_change_on_idle_cb, self, NULL);
self->state_change_on_idle_source = nm_g_idle_source_new(G_PRIORITY_DEFAULT_IDLE,
_ipv4ll_state_change_on_idle_cb,
self,
NULL);
g_source_attach(self->state_change_on_idle_source, NULL);
}
}

View file

@ -7349,7 +7349,10 @@ _init_start_with_bus(NMClient *self)
NULL);
if (id == 0) {
priv->init_data->cancel_on_idle_source =
nm_g_idle_source_new(G_PRIORITY_DEFAULT, _init_start_cancel_on_idle_cb, self, NULL);
nm_g_idle_source_new(G_PRIORITY_DEFAULT_IDLE,
_init_start_cancel_on_idle_cb,
self,
NULL);
g_source_attach(priv->init_data->cancel_on_idle_source, priv->main_context);
return;
}

View file

@ -4691,14 +4691,20 @@ _nm_utils_invoke_on_idle_start(gboolean use_timeout,
}
if (use_timeout) {
/* We use G_PRIORITY_DEFAULT_IDLE both for the with/without timeout
* case. The reason is not strong, but it seems right that the caller
* requests a lower priority than G_PRIORITY_DEFAULT. That is unlike
* what g_timeout_add() would do. */
source = nm_g_timeout_source_new(timeout_msec,
G_PRIORITY_DEFAULT,
G_PRIORITY_DEFAULT_IDLE,
_nm_utils_invoke_on_idle_cb_idle,
data,
NULL);
} else {
source =
nm_g_idle_source_new(G_PRIORITY_DEFAULT, _nm_utils_invoke_on_idle_cb_idle, data, NULL);
source = nm_g_idle_source_new(G_PRIORITY_DEFAULT_IDLE,
_nm_utils_invoke_on_idle_cb_idle,
data,
NULL);
}
/* use the current thread default context. */

View file

@ -146,7 +146,7 @@ nmcs_wait_for_objects_iterate_until_done(GMainContext *context, int timeout_msec
nm_auto_destroy_and_unref_gsource GSource *idle_source = NULL;
idle_source =
nm_g_source_attach(nm_g_idle_source_new(G_PRIORITY_DEFAULT,
nm_g_source_attach(nm_g_idle_source_new(G_PRIORITY_DEFAULT_IDLE,
_wait_for_objects_iterate_until_done_idle_cb,
&data,
NULL),
@ -364,7 +364,7 @@ nmcs_utils_poll(int poll_timeout_ms,
}
poll_task_data->source_next_poll = nm_g_source_attach(
nm_g_idle_source_new(G_PRIORITY_DEFAULT, _poll_start_cb, poll_task_data, NULL),
nm_g_idle_source_new(G_PRIORITY_DEFAULT_IDLE, _poll_start_cb, poll_task_data, NULL),
poll_task_data->context);
if (cancellable) {