Skip to content
  • Dan Winship's avatar
    gtask: remove hardcoded GTask thread-pool size · 86866a2a
    Dan Winship authored
    GTask used a 10-thread thread pool for g_task_run_in_thread() /
    g_task_run_in_thread_sync(), but this ran into problems when task
    threads blocked waiting for another g_task_run_in_thread_sync()
    operation to complete. Previously there was a workaround for this, by
    bumping up the thread limit when that case was detected, but deadlocks
    could still happen if there were non-GTask threads involved. (Eg, task
    A sends a message to thread X and waits for a response, but thread X
    needs to complete task B in a thread before returning the response to
    task A.)
    
    So, allow GTask's thread pool to be expanded dynamically, by watching
    it from the glib worker thread, and growing it (at an
    exponentially-decreasing rate) if too much time passes without any
    tasks completing. This should solve the deadlocking problems without
    causing sudden breakage in apps that assume they can queue huge
    numbers of tasks at once without consequences.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=687223
    86866a2a