mirror of
https://github.com/rakshasa/rtorrent.git
synced 2026-10-13 12:46:18 +00:00
* Added simple scheduler.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1096 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
+2
-2
@@ -1,4 +1,4 @@
|
|||||||
AC_INIT(rtorrent, 0.8.4, jaris@ifi.uio.no)
|
AC_INIT(rtorrent, 0.8.5, jaris@ifi.uio.no)
|
||||||
|
|
||||||
AM_INIT_AUTOMAKE
|
AM_INIT_AUTOMAKE
|
||||||
AM_CONFIG_HEADER(config.h)
|
AM_CONFIG_HEADER(config.h)
|
||||||
@@ -34,7 +34,7 @@ PKG_CHECK_MODULES(libcurl, libcurl >= 7.15.4,
|
|||||||
CXXFLAGS="$CXXFLAGS $libcurl_CFLAGS";
|
CXXFLAGS="$CXXFLAGS $libcurl_CFLAGS";
|
||||||
LIBS="$LIBS $libcurl_LIBS")
|
LIBS="$LIBS $libcurl_LIBS")
|
||||||
|
|
||||||
PKG_CHECK_MODULES(libtorrent, libtorrent >= 0.12.4,
|
PKG_CHECK_MODULES(libtorrent, libtorrent >= 0.12.5,
|
||||||
CXXFLAGS="$CXXFLAGS $libtorrent_CFLAGS";
|
CXXFLAGS="$CXXFLAGS $libtorrent_CFLAGS";
|
||||||
LIBS="$LIBS $libtorrent_LIBS")
|
LIBS="$LIBS $libtorrent_LIBS")
|
||||||
|
|
||||||
|
|||||||
@@ -37,7 +37,10 @@
|
|||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#include "core/manager.h"
|
#include "core/manager.h"
|
||||||
|
#include "core/download.h"
|
||||||
#include "core/download_list.h"
|
#include "core/download_list.h"
|
||||||
|
#include "core/view.h"
|
||||||
|
#include "core/view_manager.h"
|
||||||
#include "rpc/command_variable.h"
|
#include "rpc/command_variable.h"
|
||||||
|
|
||||||
#include "globals.h"
|
#include "globals.h"
|
||||||
@@ -46,7 +49,11 @@
|
|||||||
|
|
||||||
torrent::Object
|
torrent::Object
|
||||||
cmd_scheduler_simple_added(core::Download* download, const torrent::Object& rawArgs) {
|
cmd_scheduler_simple_added(core::Download* download, const torrent::Object& rawArgs) {
|
||||||
control->core()->download_list()->resume(download);
|
unsigned int numActive = (*control->view_manager()->find("active"))->size_visible();
|
||||||
|
int64_t maxActive = rpc::call_command("scheduler.max_active", torrent::Object()).as_value();
|
||||||
|
|
||||||
|
if (numActive < (uint64_t)maxActive)
|
||||||
|
control->core()->download_list()->resume(download);
|
||||||
|
|
||||||
return torrent::Object();
|
return torrent::Object();
|
||||||
}
|
}
|
||||||
@@ -55,6 +62,51 @@ torrent::Object
|
|||||||
cmd_scheduler_simple_removed(core::Download* download, const torrent::Object& rawArgs) {
|
cmd_scheduler_simple_removed(core::Download* download, const torrent::Object& rawArgs) {
|
||||||
control->core()->download_list()->pause(download);
|
control->core()->download_list()->pause(download);
|
||||||
|
|
||||||
|
core::View* viewActive = *control->view_manager()->find("active");
|
||||||
|
int64_t maxActive = rpc::call_command("scheduler.max_active", torrent::Object()).as_value();
|
||||||
|
|
||||||
|
if (viewActive->size_visible() >= maxActive)
|
||||||
|
return torrent::Object();
|
||||||
|
|
||||||
|
// The 'started' view contains all the views we may choose amongst.
|
||||||
|
core::View* viewStarted = *control->view_manager()->find("started");
|
||||||
|
|
||||||
|
for (core::View::iterator itr = viewStarted->begin_visible(), last = viewStarted->end_visible(); itr != last; itr++) {
|
||||||
|
if ((*itr)->is_active())
|
||||||
|
continue;
|
||||||
|
|
||||||
|
control->core()->download_list()->resume(*itr);
|
||||||
|
}
|
||||||
|
|
||||||
|
return torrent::Object();
|
||||||
|
}
|
||||||
|
|
||||||
|
torrent::Object
|
||||||
|
cmd_scheduler_simple_update(core::Download* download, const torrent::Object& rawArgs) {
|
||||||
|
core::View* viewActive = *control->view_manager()->find("active");
|
||||||
|
core::View* viewStarted = *control->view_manager()->find("started");
|
||||||
|
|
||||||
|
unsigned int numActive = viewActive->size_visible();
|
||||||
|
uint64_t maxActive = rpc::call_command("scheduler.max_active", torrent::Object()).as_value();
|
||||||
|
|
||||||
|
if (viewActive->size_visible() < maxActive) {
|
||||||
|
|
||||||
|
for (core::View::iterator itr = viewStarted->begin_visible(), last = viewStarted->end_visible(); itr != last; itr++) {
|
||||||
|
if ((*itr)->is_active())
|
||||||
|
continue;
|
||||||
|
|
||||||
|
control->core()->download_list()->resume(*itr);
|
||||||
|
|
||||||
|
if (++numActive >= maxActive)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
} else if (viewActive->size_visible() > maxActive) {
|
||||||
|
|
||||||
|
while (viewActive->size_visible() > maxActive)
|
||||||
|
control->core()->download_list()->pause(*viewActive->begin_visible());
|
||||||
|
}
|
||||||
|
|
||||||
return torrent::Object();
|
return torrent::Object();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -64,8 +116,9 @@ initialize_command_scheduler() {
|
|||||||
|
|
||||||
// CMD_G("scheduler.active", rak::bind_ptr_fn(&cmd_call, "view.size=active"));
|
// CMD_G("scheduler.active", rak::bind_ptr_fn(&cmd_call, "view.size=active"));
|
||||||
|
|
||||||
CMD_V("scheduler.", "max_active", value, (int64_t)-1);
|
rpc::commands.call("system.method.insert", rpc::create_object_list("scheduler.max_active", "value", (int64_t)-1));
|
||||||
|
|
||||||
CMD_D_ANY("scheduler.simple.added", rak::ptr_fn(&cmd_scheduler_simple_added));
|
CMD_D_ANY("scheduler.simple.added", rak::ptr_fn(&cmd_scheduler_simple_added));
|
||||||
CMD_D_ANY("scheduler.simple.removed", rak::ptr_fn(&cmd_scheduler_simple_removed));
|
CMD_D_ANY("scheduler.simple.removed", rak::ptr_fn(&cmd_scheduler_simple_removed));
|
||||||
|
CMD_D_ANY("scheduler.simple.update", rak::ptr_fn(&cmd_scheduler_simple_update));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -468,6 +468,7 @@ DownloadList::hash_done(Download* download) {
|
|||||||
|
|
||||||
if (rpc::call_command_value("d.get_state", rpc::make_target(download)) == 1)
|
if (rpc::call_command_value("d.get_state", rpc::make_target(download)) == 1)
|
||||||
resume(download, download->resume_flags());
|
resume(download, download->resume_flags());
|
||||||
|
//rpc::commands.call_catch("scheduler.simple.resume", rpc::make_target(download), torrent::Object(), "Download event action failed: ");
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user