Run NetSurf at priority 0 by default, dropping to priority -1 when

downloading.

svn path=/trunk/netsurf/; revision=13955
This commit is contained in:
Chris Young 2012-06-04 16:15:12 +00:00
parent 0437f81c55
commit 76b0243a0a
4 changed files with 23 additions and 0 deletions

View File

@ -83,6 +83,9 @@ enum {
AMINS_DLOAD_ABORT,
};
int downloads_in_progress = 0;
BYTE original_task_priority = 0;
struct gui_download_window *gui_download_window_create(download_context *ctx,
struct gui_window *gui)
{
@ -181,6 +184,16 @@ struct gui_download_window *gui_download_window_create(download_context *ctx,
dw->node = AddObject(window_list,AMINS_DLWINDOW);
dw->node->objstruct = dw;
/* Set task priority to -1.
* NetSurf loops without Wait()ing when downloading,
* so this gives other tasks a bit more CPU time. */
if(downloads_in_progress == 0) {
original_task_priority = SetTaskPri(FindTask(0), (BYTE)nsoption_int(download_task_pri));
LOG(("Now running at priority %d (was %d)", nsoption_int(download_task_pri), original_task_priority));
}
downloads_in_progress++;
return dw;
}
@ -268,6 +281,13 @@ void gui_download_window_done(struct gui_download_window *dw)
SetComment(dw->fname, dw->url);
if(dw->url) free(dw->url);
/* Set task priority back to what it was originally */
downloads_in_progress--;
if(downloads_in_progress == 0) {
BYTE taskpri = SetTaskPri(FindTask(0), original_task_priority);
LOG(("Now running at priority %d (was %d)", original_task_priority, taskpri));
}
DisposeObject(dw->objects[OID_MAIN]);
DelObject(dw->node);
if(queuedl) browser_window_download(bw,dln2->node.ln_Name,NULL);

View File

@ -46,6 +46,7 @@
char *arexx_shutdown; \
char *download_dir; \
bool download_notify; \
int download_task_pri; \
bool faster_scroll; \
bool scale_quality; \
bool ask_overwrite; \
@ -105,6 +106,7 @@
.arexx_shutdown = NULL, \
.download_dir = NULL, \
.download_notify = false, \
.download_task_pri = -1, \
.faster_scroll = true, \
.scale_quality = false, \
.ask_overwrite = true, \
@ -163,6 +165,7 @@
{ "arexx_shutdown", OPTION_STRING, &nsoptions.arexx_shutdown }, \
{ "download_dir", OPTION_STRING, &nsoptions.download_dir }, \
{ "download_notify", OPTION_BOOL, &nsoptions.download_notify}, \
{ "download_task_pri", OPTION_INTEGER, &nsoptions.download_task_pri}, \
{ "faster_scroll", OPTION_BOOL, &nsoptions.faster_scroll}, \
{ "scale_quality", OPTION_BOOL, &nsoptions.scale_quality}, \
{ "ask_overwrite", OPTION_BOOL, &nsoptions.ask_overwrite}, \