mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-12-25 15:06:14 +01:00
Revert "GIOScheduler: Avoid constant iteration over pending job list"
This reverts commit 2839297686
.
Conflicts:
gio/gioscheduler.c
https://bugzilla.gnome.org/show_bug.cgi?id=678576
This commit is contained in:
parent
1354ef2540
commit
115ca3d897
@ -120,17 +120,34 @@ init_scheduler (gpointer arg)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
on_job_canceled (GCancellable *cancellable,
|
remove_active_job (GIOSchedulerJob *job)
|
||||||
gpointer user_data)
|
|
||||||
{
|
{
|
||||||
GIOSchedulerJob *job = user_data;
|
GIOSchedulerJob *other_job;
|
||||||
|
GList *l;
|
||||||
job->io_priority = -1;
|
gboolean resort_jobs;
|
||||||
|
|
||||||
if (job_thread_pool != NULL)
|
G_LOCK (active_jobs);
|
||||||
|
active_jobs = g_list_delete_link (active_jobs, job->active_link);
|
||||||
|
|
||||||
|
resort_jobs = FALSE;
|
||||||
|
for (l = active_jobs; l != NULL; l = l->next)
|
||||||
|
{
|
||||||
|
other_job = l->data;
|
||||||
|
if (other_job->io_priority >= 0 &&
|
||||||
|
g_cancellable_is_cancelled (other_job->cancellable))
|
||||||
|
{
|
||||||
|
other_job->io_priority = -1;
|
||||||
|
resort_jobs = TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
G_UNLOCK (active_jobs);
|
||||||
|
|
||||||
|
if (resort_jobs &&
|
||||||
|
job_thread_pool != NULL)
|
||||||
g_thread_pool_set_sort_function (job_thread_pool,
|
g_thread_pool_set_sort_function (job_thread_pool,
|
||||||
g_io_job_compare,
|
g_io_job_compare,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -141,9 +158,7 @@ job_destroy (gpointer data)
|
|||||||
if (job->destroy_notify)
|
if (job->destroy_notify)
|
||||||
job->destroy_notify (job->data);
|
job->destroy_notify (job->data);
|
||||||
|
|
||||||
G_LOCK (active_jobs);
|
remove_active_job (job);
|
||||||
active_jobs = g_list_delete_link (active_jobs, job->active_link);
|
|
||||||
G_UNLOCK (active_jobs);
|
|
||||||
g_io_job_free (job);
|
g_io_job_free (job);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -206,11 +221,7 @@ g_io_scheduler_push_job (GIOSchedulerJobFunc job_func,
|
|||||||
job->io_priority = io_priority;
|
job->io_priority = io_priority;
|
||||||
|
|
||||||
if (cancellable)
|
if (cancellable)
|
||||||
{
|
job->cancellable = g_object_ref (cancellable);
|
||||||
job->cancellable = g_object_ref (cancellable);
|
|
||||||
g_cancellable_connect (job->cancellable, (GCallback)on_job_canceled,
|
|
||||||
job, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
job->context = g_main_context_ref_thread_default ();
|
job->context = g_main_context_ref_thread_default ();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user