Commit 529cfec3 authored by Rob Swindell's avatar Rob Swindell 💬
Browse files

Use the progress() interval argument as the time interval

Default the progress time interval to 500 milliseconds (twice a second).

Don't specify a count/call interval in the call-sites, since we really want to use time-based progress updates now only and the default probably will work fine everywhere.
parent cd72628a
Pipeline #2599 passed with stage
in 10 minutes and 18 seconds
......@@ -526,7 +526,7 @@ void sbbs_t::batch_upload()
uint x,y;
for(x=0;x<usrlibs;x++) {
progress(text[SearchingForDupes], x, usrlibs, 1);
progress(text[SearchingForDupes], x, usrlibs);
for(y=0;y<usrdirs[x];y++)
if(cfg.dir[usrdir[x][y]]->misc&DIR_DUPES
&& findfile(&cfg,usrdir[x][y], dirent->d_name, NULL))
......
......@@ -1398,10 +1398,8 @@ void sbbs_t::progress(const char* text, int count, int total, int interval)
if(cfg.node_num == 0)
return; // Don't output this for events
if((count%interval) != 0)
return;
clock_t now = msclock();
if(now - last_progress < 500)
if(now - last_progress < interval)
return;
if(text == NULL) text = "";
float pct = total ? ((float)count/total)*100.0F : 100.0F;
......
......@@ -38,7 +38,7 @@
static void ProgressLoadingMsgPtrs(void* cbdata, int count, int total)
{
sbbs_t* sbbs = ((sbbs_t*)cbdata);
sbbs->progress(sbbs->text[LoadingMsgPtrs], count, total, 10);
sbbs->progress(sbbs->text[LoadingMsgPtrs], count, total);
}
/****************************************************************************/
......@@ -64,7 +64,7 @@ void sbbs_t::putmsgptrs()
static void ProgressSearchingUsers(void* cbdata, int count, int total)
{
sbbs_t* sbbs = ((sbbs_t*)cbdata);
sbbs->progress(sbbs->text[SearchingForDupes], count, total, U_LEN*10);
sbbs->progress(sbbs->text[SearchingForDupes], count, total);
}
/****************************************************************************/
......
......@@ -847,7 +847,7 @@ public:
const char* term_charset(long term_supports = -1);
bool update_nodeterm(void);
int backfill(const char* str, float pct, int full_attr, int empty_attr);
void progress(const char* str, int count, int total, int interval=1);
void progress(const char* str, int count, int total, int interval = 500);
clock_t last_progress = 0;
bool saveline(void);
bool restoreline(void);
......
......@@ -74,7 +74,7 @@ void sbbs_t::scandirs(long mode)
if(ch==text[DirLibKeys][1]) {
k=0;
for(i=0;i<usrdirs[curlib] && !msgabort();i++) {
progress(text[Scanning], i, usrdirs[curlib], (mode & FL_ULTIME) ? 10 : 1);
progress(text[Scanning], i, usrdirs[curlib]);
if(mode&FL_ULTIME /* New-scan */
&& (cfg.lib[usrlib[curlib]]->offline_dir==usrdir[curlib][i]
|| cfg.dir[usrdir[curlib][i]]->misc&DIR_NOSCAN))
......@@ -131,7 +131,7 @@ void sbbs_t::scanalldirs(long mode)
total_dirs += usrdirs[i];
for(i=d=0;i<usrlibs;i++) {
for(j=0;j<usrdirs[i] && !msgabort();j++,d++) {
progress(text[Scanning], d, total_dirs, (mode & FL_ULTIME) ? 10 : 1);
progress(text[Scanning], d, total_dirs);
if(mode&FL_ULTIME /* New-scan */
&& (cfg.lib[usrlib[i]]->offline_dir==usrdir[i][j]
|| cfg.dir[usrdir[i][j]]->misc&DIR_NOSCAN))
......
......@@ -112,7 +112,7 @@ void sbbs_t::scansubs(long mode)
if((mode&SCAN_POLLS) && cfg.sub[usrsub[curgrp][i]]->misc&SUB_NOVOTING)
continue;
if(mode&SCAN_POLLS)
progress(text[Scanning], i, usrsubs[curgrp], 10);
progress(text[Scanning], i, usrsubs[curgrp]);
if(scanposts(usrsub[curgrp][i],mode,str))
break;
subs_scanned++;
......@@ -215,7 +215,7 @@ void sbbs_t::scanallsubs(long mode)
}
for(i=0; i<total_subs && !msgabort(); i++) {
if(mode&SCAN_POLLS)
progress(text[Scanning], i, total_subs, 10);
progress(text[Scanning], i, total_subs);
if(scanposts(sub[i],mode,str))
break;
}
......@@ -275,7 +275,7 @@ void sbbs_t::new_scan_ptr_cfg()
if(inputnstime(&t) && !(sys_status&SS_ABORT)) {
for(i=0, subs=0; i<usrgrps && online; i++) {
for(j=0;j<usrsubs[i] && online;j++) {
progress(text[LoadingMsgPtrs], subs++, total_subs, 10);
progress(text[LoadingMsgPtrs], subs++, total_subs);
checkline();
subscan[usrsub[i][j]].ptr=getmsgnum(usrsub[i][j],t);
}
......@@ -292,7 +292,7 @@ void sbbs_t::new_scan_ptr_cfg()
total_subs += usrsubs[i];
for(i=0, subs=0; i<usrgrps; i++)
for(j=0;j<usrsubs[i] && online;j++) {
progress(text[LoadingMsgPtrs], subs++, total_subs, 10);
progress(text[LoadingMsgPtrs], subs++, total_subs);
checkline();
if(s == 0) {
subscan[usrsub[i][j]].ptr = ~0;
......@@ -341,7 +341,7 @@ void sbbs_t::new_scan_ptr_cfg()
t=l;
if(inputnstime(&t) && !(sys_status&SS_ABORT)) {
for(j=0;j<usrsubs[i] && online;j++) {
progress(text[LoadingMsgPtrs], j, usrsubs[i], 10);
progress(text[LoadingMsgPtrs], j, usrsubs[i]);
checkline();
subscan[usrsub[i][j]].ptr=getmsgnum(usrsub[i][j],t);
}
......@@ -354,7 +354,7 @@ void sbbs_t::new_scan_ptr_cfg()
if(s)
s&=~0x80000000L;
for(j=0;j<usrsubs[i] && online;j++) {
progress(text[LoadingMsgPtrs], j, usrsubs[i], 10);
progress(text[LoadingMsgPtrs], j, usrsubs[i]);
checkline();
if(s == 0) {
subscan[usrsub[i][j]].ptr = ~0;
......
......@@ -61,7 +61,7 @@ ulong sbbs_t::create_filelist(const char *name, long mode)
total_dirs += usrdirs[i];
for(i=j=d=0;i<usrlibs;i++) {
for(j=0;j<usrdirs[i];j++,d++) {
progress(text[Scanning], d, total_dirs, 1);
progress(text[Scanning], d, total_dirs);
if(mode&FL_ULTIME /* New-scan */
&& (cfg.lib[usrlib[i]]->offline_dir==usrdir[i][j]
|| cfg.dir[usrdir[i][j]]->misc&DIR_NOSCAN))
......
......@@ -126,7 +126,7 @@ bool sbbs_t::uploadfile(file_t* f)
if(hashfile(&cfg, f)) {
bputs(text[SearchedForDupes]);
for(uint i=0, k=0; i < usrlibs; i++) {
progress(text[Scanning], i, usrlibs, 1);
progress(text[Scanning], i, usrlibs);
for(uint j=0; j < usrdirs[i]; j++,k++) {
if(cfg.dir[usrdir[i][j]]->misc&DIR_DUPES
&& findfile(&cfg, usrdir[i][j], /* filename: */NULL, f)) {
......@@ -321,7 +321,7 @@ bool sbbs_t::upload(uint dirnum)
return(false); /* File is already in database */
}
for(i=k=0;i<usrlibs;i++) {
progress(text[SearchingForDupes], i, usrlibs, 1);
progress(text[SearchingForDupes], i, usrlibs);
for(j=0;j<usrdirs[i];j++,k++) {
if(usrdir[i][j]==dirnum)
continue; /* we already checked this dir */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment