mirror of
https://github.com/rakshasa/rtorrent.git
synced 2026-08-12 21:22:31 +00:00
Removed SignalBitfield and replaced it with callbacks.
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
#include <ctime>
|
||||
#include <torrent/torrent.h>
|
||||
#include <torrent/system/callbacks.h>
|
||||
#include <torrent/system/thread.h>
|
||||
|
||||
#include "canvas.h"
|
||||
@@ -14,13 +15,14 @@ WindowLog::WindowLog(torrent::log_buffer* l) :
|
||||
Window(new Canvas, 0, 0, 0, extent_full, extent_static),
|
||||
m_log(l) {
|
||||
|
||||
m_task_update.slot() = std::bind(&WindowLog::receive_update, this);
|
||||
m_task_update.slot() = [this]() { receive_update(); };
|
||||
|
||||
unsigned int signal_index = torrent::main_thread::thread()->signal_bitfield()->add_signal(std::bind(&WindowLog::receive_update, this));
|
||||
m_log->lock_and_set_update_slot([this]() {
|
||||
if (m_log_updating.exchange(true) == true)
|
||||
return;
|
||||
|
||||
m_log->lock_and_set_update_slot([signal_index]() {
|
||||
torrent::main_thread::thread()->send_event_signal(signal_index, false);
|
||||
});
|
||||
torrent::main_thread::callback([this]() { receive_update(); });
|
||||
});
|
||||
}
|
||||
|
||||
WindowLog::~WindowLog() {
|
||||
@@ -52,11 +54,13 @@ WindowLog::redraw() {
|
||||
// gets updated.
|
||||
void
|
||||
WindowLog::receive_update() {
|
||||
m_log_updating = false;
|
||||
|
||||
if (!is_active())
|
||||
return;
|
||||
|
||||
iterator itr = find_older();
|
||||
extent_type height = std::min(std::distance(itr, (iterator)m_log->end()), (std::iterator_traits<iterator>::difference_type)10);
|
||||
auto itr = find_older();
|
||||
auto height = std::min(std::distance(itr, (iterator)m_log->end()), (std::iterator_traits<iterator>::difference_type)10);
|
||||
|
||||
if (height != m_max_height) {
|
||||
m_min_height = height != 0 ? 1 : 0;
|
||||
|
||||
@@ -24,6 +24,8 @@ private:
|
||||
|
||||
torrent::log_buffer* m_log;
|
||||
torrent::utils::SchedulerEntry m_task_update;
|
||||
|
||||
align_cacheline std::atomic<bool> m_log_updating{};
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
-10
@@ -141,16 +141,6 @@ main(int argc, char** argv) {
|
||||
|
||||
SignalHandler::set_sigaction_handler(SIGBUS, &handle_sigbus);
|
||||
|
||||
// SIGUSR1 is used for interrupting polling, forcing the target
|
||||
// thread to process new non-socket events.
|
||||
//
|
||||
// LibTorrent uses sockets for this purpose on Solaris and other
|
||||
// platforms that do not properly pass signals to the target
|
||||
// threads. Use '--enable-interrupt-socket' when configuring
|
||||
// LibTorrent to enable this workaround.
|
||||
if (torrent::system::Thread::should_handle_sigusr1())
|
||||
SignalHandler::set_handler(SIGUSR1, []() {});
|
||||
|
||||
torrent::log_add_group_output(torrent::LOG_NOTICE, "important");
|
||||
torrent::log_add_group_output(torrent::LOG_DHT_ERROR, "important");
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
#include <torrent/exceptions.h>
|
||||
#include <torrent/torrent.h>
|
||||
#include <torrent/system/callbacks.h>
|
||||
#include <torrent/system/thread.h>
|
||||
|
||||
#include "display/frame.h"
|
||||
@@ -17,11 +18,12 @@ namespace ui {
|
||||
ElementLogComplete::ElementLogComplete(torrent::log_buffer* l) :
|
||||
m_log(l) {
|
||||
|
||||
unsigned int signal_index = torrent::main_thread::thread()->signal_bitfield()->add_signal(std::bind(&ElementLogComplete::received_update, this));
|
||||
m_log->lock_and_set_update_slot([this]() {
|
||||
if (m_log_updating.exchange(true) == true)
|
||||
return;
|
||||
|
||||
m_log->lock_and_set_update_slot([signal_index]() {
|
||||
torrent::main_thread::thread()->send_event_signal(signal_index, false);
|
||||
});
|
||||
torrent::main_thread::callback([this]() { received_update(); });
|
||||
});
|
||||
}
|
||||
|
||||
void
|
||||
@@ -59,6 +61,8 @@ ElementLogComplete::window() {
|
||||
|
||||
void
|
||||
ElementLogComplete::received_update() {
|
||||
m_log_updating = false;
|
||||
|
||||
if (m_window != NULL)
|
||||
m_window->mark_dirty();
|
||||
}
|
||||
|
||||
@@ -30,6 +30,8 @@ private:
|
||||
WLogComplete* m_window{};
|
||||
|
||||
torrent::log_buffer* m_log;
|
||||
|
||||
align_cacheline std::atomic<bool> m_log_updating{};
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user