Removed priority_queue and rak/timer.

This commit is contained in:
Jari Sundell
2025-05-02 11:03:51 +02:00
committed by GitHub
parent 6f8c1246dc
commit 85e74b5542
65 changed files with 384 additions and 1933 deletions
+29 -60
View File
@@ -1,39 +1,3 @@
// rTorrent - BitTorrent client
// Copyright (C) 2005-2011, Jari Sundell
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// In addition, as a special exception, the copyright holders give
// permission to link the code of portions of this program with the
// OpenSSL library under certain conditions as described in each
// individual source file, and distribute linked combinations
// including the two.
//
// You must obey the GNU General Public License in all respects for
// all of the code used other than OpenSSL. If you modify file(s)
// with this exception, you may extend this exception to your version
// of the file(s), but you are not obligated to do so. If you do not
// wish to do so, delete this exception statement from your version.
// If you delete this exception statement from all source files in the
// program, then also delete it here.
//
// Contact: Jari Sundell <jaris@ifi.uio.no>
//
// Skomakerveien 33
// 3185 Skoppum, NORWAY
#include "config.h"
#include <stdexcept>
@@ -46,74 +10,79 @@
namespace display {
Manager::Manager() :
m_forceRedraw(false) {
Manager::Manager() {
m_scheduler.external_set_thread_id(std::this_thread::get_id());
m_taskUpdate.slot() = std::bind(&Manager::receive_update, this);
m_task_update.slot() = std::bind(&Manager::receive_update, this);
}
Manager::~Manager() {
priority_queue_erase(&taskScheduler, &m_taskUpdate);
torrent::this_thread::scheduler()->erase(&m_task_update);
}
void
Manager::force_redraw() {
m_forceRedraw = true;
m_force_redraw = true;
}
void
Manager::schedule(Window* w, rak::timer t) {
rak::priority_queue_update(&m_scheduler, w->task_update(), t);
schedule_update(50000);
Manager::schedule(Window* w, std::chrono::microseconds t) {
m_scheduler.external_set_cached_time(torrent::this_thread::cached_time());
m_scheduler.update_wait_until(w->task_update(), t);
schedule_update(50ms);
}
void
Manager::unschedule(Window* w) {
rak::priority_queue_erase(&m_scheduler, w->task_update());
schedule_update(50000);
m_scheduler.external_set_cached_time(torrent::this_thread::cached_time());
m_scheduler.erase(w->task_update());
schedule_update(50ms);
}
void
Manager::adjust_layout() {
Canvas::redraw_std();
m_rootFrame.balance(0, 0, Canvas::get_screen_width(), Canvas::get_screen_height());
m_root_frame.balance(0, 0, Canvas::get_screen_width(), Canvas::get_screen_height());
schedule_update(0);
schedule_update(0ms);
}
void
Manager::receive_update() {
if (m_forceRedraw) {
m_forceRedraw = false;
if (m_force_redraw) {
m_force_redraw = false;
display::Canvas::resize_term(display::Canvas::term_size());
Canvas::redraw_std();
adjust_layout();
m_rootFrame.redraw();
m_root_frame.redraw();
}
Canvas::refresh_std();
rak::priority_queue_perform(&m_scheduler, cachedTime);
m_rootFrame.refresh();
m_scheduler.external_perform(torrent::this_thread::cached_time());
m_root_frame.refresh();
Canvas::do_update();
m_timeLastUpdate = cachedTime;
schedule_update(50000);
m_time_last_update = torrent::this_thread::cached_time();
schedule_update(50ms);
}
void
Manager::schedule_update(uint32_t minInterval) {
Manager::schedule_update(std::chrono::microseconds min_interval) {
if (m_scheduler.empty()) {
rak::priority_queue_erase(&taskScheduler, &m_taskUpdate);
torrent::this_thread::scheduler()->erase(&m_task_update);
return;
}
if (!m_taskUpdate.is_queued() || m_taskUpdate.time() > m_scheduler.top()->time()) {
rak::priority_queue_update(&taskScheduler, &m_taskUpdate, std::max(m_scheduler.top()->time(), m_timeLastUpdate + minInterval));
}
if (m_task_update.is_scheduled() && m_task_update.time() <= m_scheduler.front()->time())
return;
torrent::this_thread::scheduler()->update_wait_until(&m_task_update, std::max(m_scheduler.front()->time(), m_time_last_update + min_interval));
}
}