scheduleQpcV4AllPagesPrebuild method

void scheduleQpcV4AllPagesPrebuild({
  1. Duration delay = const Duration(seconds: 2),
})

جدولة تحضير كل صفحات QPC v4 بعد فترة خمول. الهدف: منع منافسة CPU أثناء تقليب الصفحات.

Implementation

void scheduleQpcV4AllPagesPrebuild(
    {Duration delay = const Duration(seconds: 2)}) {
  if (!isQpcV4Enabled) return;
  if (_qpcV4BlocksByPage.length >= 604) return;
  if (_qpcV4PrebuildStarted) return;
  log('Scheduling QPC v4 prebuild for all pages after $delay of idle time',
      name: 'QPCv4');

  _qpcV4IdlePrebuildTimer?.cancel();
  _qpcV4IdlePrebuildTimer = Timer(delay, () {
    if (!isQpcV4Enabled) return;
    if (_qpcV4PrebuildStarted) return;
    Future(() => ensureQpcV4AllPagesPrebuilt());
  });
}