* Fixed the log redraw which didn't happen as the display's scheduler

didn't get re-added to the task scheduler until a new event happened.

* Added redraw delay interval of 100ms, consider 50ms.

* Removed exceptions from core::DownloadStore::save.

* Added load, load_run, tied_stop and tied_remove to man-page.

* Cleaned up the command/option instances, move them to Control.

* PCB::load_up_chunk grabbed the errno from m_downChunk, not m_upChunk.

* Various string operations were moved to rak/string_manip.h.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@617 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
rakshasa
2006-01-06 21:14:49 +00:00
parent 4431fd1652
commit f32c15878a
33 changed files with 471 additions and 482 deletions
+54 -17
View File
@@ -47,6 +47,28 @@
namespace display {
Manager::Manager() {
m_taskUpdate.set_slot(rak::mem_fn(this, &Manager::receive_update));
}
Manager::~Manager() {
priority_queue_erase(&taskScheduler, &m_taskUpdate);
}
Manager::iterator
Manager::insert(iterator pos, Window* w) {
return Base::insert(pos, w);
}
// Swap with the function below.
Manager::iterator
Manager::erase(iterator pos) {
if (pos != end())
return erase(*pos);
else
return end();
}
Manager::iterator
Manager::erase(Window* w) {
iterator itr = std::find(begin(), end(), w);
@@ -62,6 +84,19 @@ Manager::find(Window* w) {
return std::find(begin(), end(), w);
}
void
Manager::schedule(Window* w, rak::timer t) {
rak::priority_queue_erase(&m_scheduler, w->task_update());
rak::priority_queue_insert(&m_scheduler, w->task_update(), t);
schedule_update();
}
void
Manager::unschedule(Window* w) {
rak::priority_queue_erase(&m_scheduler, w->task_update());
schedule_update();
}
void
Manager::adjust_layout() {
int staticHeight = std::for_each(begin(), end(),
@@ -95,28 +130,30 @@ Manager::adjust_layout() {
}
void
Manager::do_update() {
Manager::receive_update() {
Canvas::refresh_std();
// std::list<rak::priority_item*> workQueue;
// std::copy(rak::queue_popper(displayScheduler, rak::bind2nd(std::mem_fun(&rak::priority_item::compare), cachedTime)),
// rak::queue_popper(displayScheduler, rak::bind2nd(std::mem_fun(&rak::priority_item::compare), rak::timer())),
// std::back_inserter(workQueue));
// std::for_each(workQueue.begin(), workQueue.end(), std::mem_fun(&rak::priority_item::clear_time));
// std::for_each(workQueue.begin(), workQueue.end(), std::mem_fun(&rak::priority_item::call));
while (!displayScheduler.empty() && displayScheduler.top()->time() <= cachedTime) {
rak::priority_item* v = displayScheduler.top();
displayScheduler.pop();
v->clear_time();
v->call();
}
rak::priority_queue_perform(&m_scheduler, cachedTime);
std::for_each(begin(), end(), rak::if_then(std::mem_fun(&Window::is_active), std::mem_fun(&Window::refresh)));
Canvas::do_update();
m_timeLastUpdate = cachedTime;
schedule_update();
}
void
Manager::schedule_update() {
if (m_scheduler.empty()) {
rak::priority_queue_erase(&taskScheduler, &m_taskUpdate);
return;
}
if (!m_taskUpdate.is_queued() || m_taskUpdate.time() > m_scheduler.top()->time()) {
rak::priority_queue_erase(&taskScheduler, &m_taskUpdate);
rak::priority_queue_insert(&taskScheduler, &m_taskUpdate,
std::max(m_scheduler.top()->time(), m_timeLastUpdate + 100000));
}
}
}
+20 -6
View File
@@ -38,6 +38,7 @@
#define RTORRENT_DISPLAY_MANAGER_H
#include <list>
#include <rak/priority_queue_default.h>
namespace display {
@@ -57,19 +58,32 @@ public:
using Base::rbegin;
using Base::rend;
using Base::insert;
using Base::erase;
using Base::push_front;
using Base::push_back;
iterator erase(Window* w);
Manager();
~Manager();
iterator find(Window* w);
iterator insert(iterator pos, Window* w);
iterator erase(iterator pos);
iterator erase(Window* w);
void adjust_layout();
void do_update();
iterator find(Window* w);
void schedule(Window* w, rak::timer t);
void unschedule(Window* w);
void adjust_layout();
private:
void receive_update();
void schedule_update();
rak::timer m_timeLastUpdate;
rak::priority_queue_default m_scheduler;
rak::priority_item m_taskUpdate;
};
}
+5 -3
View File
@@ -42,7 +42,9 @@
namespace display {
Window::Slot Window::m_slotAdjust;
Window::SlotTimer Window::m_slotSchedule;
Window::SlotWindow Window::m_slotUnschedule;
Window::Slot Window::m_slotAdjust;
Window::Window(Canvas* c, bool d, int h) :
m_canvas(c),
@@ -54,7 +56,7 @@ Window::Window(Canvas* c, bool d, int h) :
}
Window::~Window() {
priority_queue_erase(&displayScheduler, &m_taskUpdate);
m_slotUnschedule(this);
delete m_canvas;
}
@@ -63,7 +65,7 @@ Window::set_active(bool a) {
if (a)
mark_dirty();
else
priority_queue_erase(&displayScheduler, &m_taskUpdate);
m_slotUnschedule(this);
m_active = a;
}
+13 -11
View File
@@ -38,7 +38,7 @@
#define RTORRENT_WINDOW_BASE_H
#include <rak/timer.h>
#include <sigc++/slot.h>
#include <rak/functional.h>
#include "canvas.h"
#include "globals.h"
@@ -46,10 +46,13 @@
namespace display {
class Canvas;
class Manager;
class Window {
public:
typedef sigc::slot0<void> Slot;
typedef rak::mem_fun0<Manager, void> Slot;
typedef rak::mem_fun1<Manager, void, Window*> SlotWindow;
typedef rak::mem_fun2<Manager, void, Window*, rak::timer> SlotTimer;
Window(Canvas* c = NULL, bool d = false, int h = 1);
@@ -59,8 +62,6 @@ public:
bool is_dynamic() { return m_dynamic; }
bool is_dirty() { return m_taskUpdate.is_queued(); }
//utils::rak::timer get_next_draw() { return m_nextDraw; }
int get_min_height() { return m_minHeight; }
bool get_active() { return m_active; }
@@ -69,16 +70,23 @@ public:
void refresh() { m_canvas->refresh(); }
void resize(int x, int y, int w, int h);
void mark_dirty();
void mark_dirty() { m_slotSchedule(this, cachedTime + 1); }
virtual void redraw() = 0;
rak::priority_item* task_update() { return &m_taskUpdate; }
// Slot for adjust and refresh.
static void slot_schedule(SlotTimer s) { m_slotSchedule = s; }
static void slot_unschedule(SlotWindow s) { m_slotUnschedule = s; }
static void slot_adjust(Slot s) { m_slotAdjust = s; }
protected:
Window(const Window&);
void operator = (const Window&);
static SlotTimer m_slotSchedule;
static SlotWindow m_slotUnschedule;
static Slot m_slotAdjust;
Canvas* m_canvas;
@@ -90,12 +98,6 @@ protected:
rak::priority_item m_taskUpdate;
};
inline void
Window::mark_dirty() {
priority_queue_erase(&displayScheduler, &m_taskUpdate);
priority_queue_insert(&displayScheduler, &m_taskUpdate, cachedTime + 1);
}
}
#endif
+1 -1
View File
@@ -60,7 +60,7 @@ WindowDownloadList::~WindowDownloadList() {
void
WindowDownloadList::redraw() {
priority_queue_insert(&displayScheduler, &m_taskUpdate, (cachedTime + 1000000).round_seconds());
m_slotSchedule(this, (cachedTime + 1000000).round_seconds());
m_canvas->erase();
+1 -1
View File
@@ -54,7 +54,7 @@ WindowDownloadStatusbar::WindowDownloadStatusbar(core::Download* d) :
void
WindowDownloadStatusbar::redraw() {
priority_queue_insert(&displayScheduler, &m_taskUpdate, (cachedTime + 1000000).round_seconds());
m_slotSchedule(this, (cachedTime + 1000000).round_seconds());
m_canvas->erase();
+1 -1
View File
@@ -54,7 +54,7 @@ WindowFileList::WindowFileList(core::Download* d, unsigned int* focus) :
void
WindowFileList::redraw() {
priority_queue_insert(&displayScheduler, &m_taskUpdate, (cachedTime + 10 * 1000000).round_seconds());
m_slotSchedule(this, (cachedTime + 10 * 1000000).round_seconds());
m_canvas->erase();
if (m_download->get_download().size_file_entries() == 0 ||
+1 -1
View File
@@ -58,7 +58,7 @@ WindowHttpQueue::WindowHttpQueue(core::HttpQueue* q) :
void
WindowHttpQueue::redraw() {
priority_queue_insert(&displayScheduler, &m_taskUpdate, (cachedTime + 1000000).round_seconds());
m_slotSchedule(this, (cachedTime + 1000000).round_seconds());
cleanup_list();
+6 -6
View File
@@ -37,11 +37,11 @@
#include "config.h"
#include <stdexcept>
#include <rak/string_manip.h>
#include <torrent/rate.h>
#include "core/download.h"
#include "utils/parse.h"
#include "canvas.h"
#include "utils.h"
#include "window_peer_info.h"
@@ -57,14 +57,14 @@ WindowPeerInfo::WindowPeerInfo(core::Download* d, PList* l, PList::iterator* f)
void
WindowPeerInfo::redraw() {
priority_queue_insert(&displayScheduler, &m_taskUpdate, (cachedTime + 1000000).round_seconds());
m_slotSchedule(this, (cachedTime + 1000000).round_seconds());
m_canvas->erase();
int y = 0;
torrent::Download d = m_download->get_download();
m_canvas->print(0, y++, "Hash: %s", utils::string_to_hex(d.info_hash()).c_str());
m_canvas->print(0, y++, "Id: %s", utils::escape_string(d.local_id()).c_str());
m_canvas->print(0, y++, "Hash: %s", rak::transform_hex(d.info_hash()).c_str());
m_canvas->print(0, y++, "Id: %s", rak::copy_escape_html(d.local_id()).c_str());
m_canvas->print(0, y++, "Chunks: %u / %u * %u",
d.chunks_done(),
d.chunks_total(),
@@ -97,8 +97,8 @@ WindowPeerInfo::redraw() {
m_canvas->print(0, y++, "*** Peer Info ***");
m_canvas->print(0, y++, "DNS: %s:%hu", (*m_focus)->address().c_str(), (*m_focus)->port());
m_canvas->print(0, y++, "Id: %s" , utils::escape_string((*m_focus)->id()).c_str());
m_canvas->print(0, y++, "Options: %s" , utils::string_to_hex(std::string((*m_focus)->options(), 8)).c_str());
m_canvas->print(0, y++, "Id: %s" , rak::copy_escape_html((*m_focus)->id()).c_str());
m_canvas->print(0, y++, "Options: %s" , rak::transform_hex(std::string((*m_focus)->options(), 8)).c_str());
m_canvas->print(0, y++, "Snubbed: %s", (*m_focus)->is_snubbed() ? "yes" : "no");
m_canvas->print(0, y++, "Connected: %s", (*m_focus)->is_incoming() ? "remote" : "local");
+1 -1
View File
@@ -56,7 +56,7 @@ WindowPeerList::WindowPeerList(core::Download* d, PList* l, PList::iterator* f)
void
WindowPeerList::redraw() {
priority_queue_insert(&displayScheduler, &m_taskUpdate, (cachedTime + 1000000).round_seconds());
m_slotSchedule(this, (cachedTime + 1000000).round_seconds());
m_canvas->erase();
int x = 2;
+1 -1
View File
@@ -56,7 +56,7 @@ WindowStatusbar::WindowStatusbar(core::Manager* c) :
void
WindowStatusbar::redraw() {
priority_queue_insert(&displayScheduler, &m_taskUpdate, (cachedTime + 1000000).round_seconds());
m_slotSchedule(this, (cachedTime + 1000000).round_seconds());
m_canvas->erase();
+1 -1
View File
@@ -48,7 +48,7 @@ WindowTitle::WindowTitle(const std::string& s) :
void
WindowTitle::redraw() {
priority_queue_insert(&displayScheduler, &m_taskUpdate, (cachedTime + 1000000).round_seconds());
m_slotSchedule(this, (cachedTime + 1000000).round_seconds());
m_canvas->erase();
m_canvas->print(std::max(0, (m_canvas->get_width() - (int)m_title.size()) / 2 - 4), 0,
+4 -4
View File
@@ -37,10 +37,10 @@
#include "config.h"
#include <stdexcept>
#include <rak/algorithm.h>
#include <rak/string_manip.h>
#include "core/download.h"
#include "rak/algorithm.h"
#include "utils/parse.h"
#include "window_tracker_list.h"
@@ -55,7 +55,7 @@ WindowTrackerList::WindowTrackerList(core::Download* d, unsigned int* focus) :
void
WindowTrackerList::redraw() {
// TODO: Make this depend on tracker signal.
priority_queue_insert(&displayScheduler, &m_taskUpdate, (cachedTime + 10 * 1000000).round_seconds());
m_slotSchedule(this, (cachedTime + 10 * 1000000).round_seconds());
m_canvas->erase();
int pos = 0;
@@ -87,7 +87,7 @@ WindowTrackerList::redraw() {
m_canvas->print(0, pos++, "%c Group: %2i Id: %s Focus: %s Enabled: %s Open: %s",
range.first == *m_focus ? '*' : ' ',
t.group(),
utils::escape_string(t.tracker_id()).c_str(),
rak::copy_escape_html(t.tracker_id()).c_str(),
range.first == m_download->get_download().tracker_focus() ? "yes" : " no",
t.is_enabled() ? "yes" : " no",
t.is_open() ? "yes" : " no");