Replaced Thread::next_timeout_usec().

This commit is contained in:
Jari Sundell
2025-04-15 19:39:40 +02:00
committed by GitHub
parent 25f729fab5
commit dd221ac66a
11 changed files with 19 additions and 200 deletions
+1
View File
@@ -14,6 +14,7 @@
#define RTORRENT_CORE_VIEW_DOWNLOADS_H
#include <functional>
#include <list>
#include <string>
#include <vector>
-36
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 <algorithm>
-36
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 "input_event.h"
-36
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
#ifndef RTORRENT_INPUT_INPUT_EVENT_H
#define RTORRENT_INPUT_INPUT_EVENT_H
+1 -37
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 <algorithm>
@@ -64,7 +28,7 @@ Manager::pressed(int key) {
if (m_textInput != NULL)
m_textInput->pressed(key);
else
std::find_if(rbegin(), rend(), [&key](Bindings* bind) { return bind->pressed(key); });
[[maybe_unused]] auto result = std::find_if(rbegin(), rend(), [&key](Bindings* bind) { return bind->pressed(key); });
}
}
-36
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
#ifndef RTORRENT_INPUT_MANAGER_H
#define RTORRENT_INPUT_MANAGER_H
+1 -2
View File
@@ -191,8 +191,7 @@ main(int argc, char** argv) {
torrent::Poll::slot_create_poll() = std::bind(&core::create_poll);
torrent::initialize();
torrent::main_thread()->slot_do_work() = std::bind(&client_perform);
torrent::main_thread()->slot_next_timeout() = std::bind(&client_next_timeout);
torrent::set_main_thread_slots(std::bind(&client_perform), std::bind(&client_next_timeout));
worker_thread = new ThreadWorker();
worker_thread->init_thread();
+2
View File
@@ -86,6 +86,8 @@ SCgi::open(void* sa, unsigned int length) {
}
}
// TODO: Verify this is run in correct thread, also only ever call poll methods from thread_self.
void
SCgi::activate() {
worker_thread->poll()->open(this);
+11 -12
View File
@@ -9,6 +9,7 @@
#include <rak/error_number.h>
#include <torrent/exceptions.h>
#include <torrent/torrent.h>
#include <torrent/utils/chrono.h>
#include <torrent/utils/log.h>
#include <unistd.h>
@@ -32,25 +33,23 @@ ThreadBase::queue_stop_thread() {
priority_queue_insert(&m_taskScheduler, &m_taskShutdown, cachedTime);
}
int64_t
ThreadBase::next_timeout_usec() {
std::chrono::microseconds
ThreadBase::next_timeout() {
if (m_taskScheduler.empty())
return rak::timer::from_seconds(600).usec();
else if (m_taskScheduler.top()->time() <= cachedTime)
return 0;
else
return (m_taskScheduler.top()->time() - cachedTime).usec();
return std::chrono::microseconds(10min);
// TODO: Thread-specific cachedTime.
cachedTime = rak::timer::current();
// if (!taskScheduler.empty())
// return std::max(taskScheduler.top()->time() - cachedTime, rak::timer()).usec();
// else
// return rak::timer::from_seconds(600).usec();
if (m_taskScheduler.top()->time() <= cachedTime)
return std::chrono::microseconds(0);
return std::chrono::microseconds((m_taskScheduler.top()->time() - cachedTime).usec());
}
void
ThreadBase::call_events() {
cachedTime = rak::timer::current();
rak::priority_queue_perform(&m_taskScheduler, cachedTime);
process_callbacks();
+2 -4
View File
@@ -32,10 +32,8 @@ public:
// void queue_item(thread_base_func newFunc);
protected:
int64_t next_timeout_usec();
// void call_queued_items();
virtual void call_events();
void call_events() override;
std::chrono::microseconds next_timeout() override;
// TODO: Add thread name.
+1 -1
View File
@@ -70,7 +70,7 @@ ElementDownloadList::ElementDownloadList() :
}
void
ElementDownloadList::activate(display::Frame* frame, bool focus) {
ElementDownloadList::activate(display::Frame* frame, [[maybe_unused]] bool focus) {
if (is_active())
throw torrent::internal_error("ui::ElementDownloadList::activate(...) is_active().");