[Libreoffice-commits] core.git: vcl/inc vcl/source

Jan-Marek Glogowski (via logerrit) logerrit at kemper.freedesktop.org
Wed Dec 16 22:04:02 UTC 2020


 vcl/inc/schedulerimpl.hxx    |   12 ++++++++++++
 vcl/source/app/scheduler.cxx |    3 +++
 vcl/source/app/svapp.cxx     |    3 ++-
 3 files changed, 17 insertions(+), 1 deletion(-)

New commits:
commit 8b092e2e10b7864966a77dd1225acc1f43a12ee4
Author:     Jan-Marek Glogowski <glogow at fbihome.de>
AuthorDate: Wed Dec 16 10:51:33 2020 +0100
Commit:     Jan-Marek Glogowski <glogow at fbihome.de>
CommitDate: Wed Dec 16 23:03:23 2020 +0100

    Scheduler assert mbInScheduler state
    
    Since the introduction of the scheduler stack, this became merely
    a debugging and assertion hint. So actually handle it like that
    and don't use it for any decisions, even in debug code.
    
    Change-Id: Ibeb247279d9e94ea4ff3a7b4652e98e179d6c76e
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107824
    Tested-by: Jenkins
    Reviewed-by: Jan-Marek Glogowski <glogow at fbihome.de>

diff --git a/vcl/inc/schedulerimpl.hxx b/vcl/inc/schedulerimpl.hxx
index f6d5dda708bd..56563ded4cc9 100644
--- a/vcl/inc/schedulerimpl.hxx
+++ b/vcl/inc/schedulerimpl.hxx
@@ -32,6 +32,18 @@ struct ImplSchedulerData final
     Task*              mpTask;        ///< Pointer to VCL Task instance
     sal_uInt64         mnUpdateTime;  ///< Last Update Time
     TaskPriority       mePriority;    ///< Task priority
+    /**
+     * Is the Task currently processed / on the stack?
+     *
+     * Since the introduction of the scheduler stack, this became merely a
+     * debugging and assertion hint. No decisions are anymore made based on
+     * this, because invoked Tasks are removed from the scheduler lists and
+     * placed on the stack, so no code should actually ever find one, where
+     * mbInScheduler is true (I don't see a reason to walk the stack for
+     * normal Scheduler usage, that is).
+     *
+     * This was originally used to prevent invoking Tasks recursively.
+     **/
     bool               mbInScheduler; ///< Task currently processed?
 
     const char *GetDebugName() const;
diff --git a/vcl/source/app/scheduler.cxx b/vcl/source/app/scheduler.cxx
index da8511bffa55..b325f9238a7d 100644
--- a/vcl/source/app/scheduler.cxx
+++ b/vcl/source/app/scheduler.cxx
@@ -442,6 +442,7 @@ bool Scheduler::ProcessTaskScheduling()
         // prepare Scheduler object for deletion after handling
         pTask->SetDeletionFlags();
 
+        assert(!pMostUrgent->mbInScheduler);
         pMostUrgent->mbInScheduler = true;
 
         // always push the stack, as we don't traverse the whole list to push later
@@ -479,6 +480,8 @@ bool Scheduler::ProcessTaskScheduling()
             std::abort();
         }
         Lock();
+
+        assert(pMostUrgent->mbInScheduler);
         pMostUrgent->mbInScheduler = false;
 
         SAL_INFO( "vcl.schedule", tools::Time::GetSystemTicks() << " "
diff --git a/vcl/source/app/svapp.cxx b/vcl/source/app/svapp.cxx
index 340d7b91d4fe..c1cbd6d093ce 100644
--- a/vcl/source/app/svapp.cxx
+++ b/vcl/source/app/svapp.cxx
@@ -479,7 +479,8 @@ void Scheduler::ProcessEventsToIdle()
         const ImplSchedulerData* pSchedulerData = pSVData->maSchedCtx.mpFirstSchedulerData[nTaskPriority];
         while (pSchedulerData)
         {
-            if (pSchedulerData->mpTask && !pSchedulerData->mbInScheduler)
+            assert(!pSchedulerData->mbInScheduler);
+            if (pSchedulerData->mpTask)
             {
                 Idle *pIdle = dynamic_cast<Idle*>(pSchedulerData->mpTask);
                 if (pIdle && pIdle->IsActive())


More information about the Libreoffice-commits mailing list