summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2025-02-14 14:20:21 +0100
committerMiklos Vajna <vmiklos@collabora.com>2025-02-17 09:43:05 +0100
commit9e82453c2d5e075ee2eed8330f5b710e4a7a6df7 (patch)
tree8584425e399095d7c78480e89e7651bd1942f5f1 /vcl
parentaec5e1c566a935fd4f650243e298cd79b10a0bd6 (diff)
cool#11064 vcl lok: expose info about the scheduler
A LOK client can interrupt the vcl main loop in its 'any input' callback. When making that decision, it's useful in case it can know what's the priority of the most urgent job, for example it may want core to still finish high priority tasks, but not idle ones. Add a LOK API to expose this info. Keep it minimal, so it's realistic to call this frequently from a LOK client. Change-Id: Id51668eb8156067e60d6fd0f33606c65858008a9 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/181761 Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Tested-by: Jenkins
Diffstat (limited to 'vcl')
-rw-r--r--vcl/source/app/scheduler.cxx44
1 files changed, 44 insertions, 0 deletions
diff --git a/vcl/source/app/scheduler.cxx b/vcl/source/app/scheduler.cxx
index 6234e6355117..eb3acf65c8a4 100644
--- a/vcl/source/app/scheduler.cxx
+++ b/vcl/source/app/scheduler.cxx
@@ -41,6 +41,7 @@
#include <salinst.hxx>
#include <comphelper/emscriptenthreading.hxx>
#include <comphelper/profilezone.hxx>
+#include <tools/json_writer.hxx>
#include <schedulerimpl.hxx>
namespace {
@@ -301,6 +302,49 @@ Scheduler::IdlesLockGuard::~IdlesLockGuard()
osl_atomic_decrement(&rSchedCtx.mnIdlesLockCount);
}
+void Scheduler::dumpAsJSON(tools::JsonWriter& rJsonWriter)
+{
+ // Similar to Scheduler::CallbackTaskScheduling(), figure out the most urgent priority, but
+ // don't actually invoke any task.
+ int nMostUrgentPriority = -1;
+ ImplSVData* pSVData = ImplGetSVData();
+ ImplSchedulerContext& rSchedCtx = pSVData->maSchedCtx;
+ if (!rSchedCtx.mbActive || rSchedCtx.mnTimerPeriod == InfiniteTimeoutMs)
+ {
+ rJsonWriter.put("mostUrgentPriority", nMostUrgentPriority);
+ return;
+ }
+
+ sal_uInt64 nTime = tools::Time::GetSystemTicks();
+ if (nTime < rSchedCtx.mnTimerStart + rSchedCtx.mnTimerPeriod - 1)
+ {
+ rJsonWriter.put("mostUrgentPriority", nMostUrgentPriority);
+ return;
+ }
+
+ for (int nTaskPriority = 0; nTaskPriority < PRIO_COUNT; ++nTaskPriority)
+ {
+ ImplSchedulerData* pSchedulerData = rSchedCtx.mpFirstSchedulerData[nTaskPriority];
+ while (pSchedulerData)
+ {
+ Task* pTask = pSchedulerData->mpTask;
+ if (pTask && pTask->IsActive())
+ {
+ // Const, doesn't modify the task.
+ sal_uInt64 nReadyPeriod = pTask->UpdateMinPeriod(nTime);
+ if (nReadyPeriod == ImmediateTimeoutMs)
+ {
+ nMostUrgentPriority = nTaskPriority;
+ rJsonWriter.put("mostUrgentPriority", nMostUrgentPriority);
+ return;
+ }
+ }
+ pSchedulerData = pSchedulerData->mpNext;
+ }
+ }
+ rJsonWriter.put("mostUrgentPriority", nMostUrgentPriority);
+}
+
inline void Scheduler::UpdateSystemTimer( ImplSchedulerContext &rSchedCtx,
const sal_uInt64 nMinPeriod,
const bool bForce, const sal_uInt64 nTime )