From: Jan S. <st...@us...> - 2004-08-12 13:40:27
|
Update of /cvsroot/bidwatcher/bidwatcher In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16586 Modified Files: Tag: STABLE_1_3 bidwatcher.cpp Log Message: another patch by T.E.: better update-timer-setup Index: bidwatcher.cpp =================================================================== RCS file: /cvsroot/bidwatcher/bidwatcher/Attic/bidwatcher.cpp,v retrieving revision 1.171.2.44 retrieving revision 1.171.2.45 diff -u -d -r1.171.2.44 -r1.171.2.45 --- bidwatcher.cpp 11 Aug 2004 09:30:24 -0000 1.171.2.44 +++ bidwatcher.cpp 12 Aug 2004 13:40:15 -0000 1.171.2.45 @@ -2415,6 +2415,39 @@ return pixmapwid; } +void timeout1Up() +{ + int minTimeLeft; + int time_to_next_update; + int max_update; + + minTimeLeft = timeToNextEnd() - (int)((avg_load_time + 500)/1000); + + if (minTimeLeft > 0 && minTimeLeft < snipeDelay + 2) + // don't interfere with the snipe + time_to_next_update = (minTimeLeft + 3) * 1000; + else if (minTimeLeft < 3*60) // watch it even closer + time_to_next_update = update_prio1_interval *1000; + else if (minTimeLeft < 15*60) // watch it closely + time_to_next_update = update_prio2_interval *1000; + else if (minTimeLeft < 2*60*60) // no sense in wasting bandwidth... + time_to_next_update = update_prio3_interval *1000; + else // *yawn* + time_to_next_update = update_prio4_interval *1000; + + max_update = (int)(avg_load_time * 2); + if (time_to_next_update < max_update) { +#ifdef DEBUG_NETWORK + fprintf(stderr, "poor network response: " + "Adjusting update time from %d to %d\n", + time_to_next_update, max_update); +#endif + time_to_next_update = max_update; + } + + g_timeout_add_full(100,time_to_next_update,updatelist_callback,NULL,NULL); +} + void init() { @@ -2766,9 +2799,9 @@ // getAdultCookie(authID, authPASS); timer1Up(); - gtk_timeout_add(1000, secondticker_callback, NULL); - gtk_timeout_add(BIGDELAY, bigdelay_callback, NULL); - gtk_timeout_add(30*1000, updatelist_callback, NULL); + g_timeout_add(1000, secondticker_callback, NULL); + g_timeout_add(BIGDELAY, bigdelay_callback, NULL); + timeout1Up(); // until we know better, don't waste bandwidth } // end constructor @@ -3325,7 +3358,7 @@ showStatus(""); UpdateList(); updateInProgress = FALSE; - updatelist_callback(NULL); + timeout1Up(); WriteAucFile(); return NewAuction; } @@ -3478,6 +3511,7 @@ return TRUE; } + ////////////////////////////////////////////////////////////////////////////// // bigUpdate // triggers an UpdateAll every BIGDELAY mSeconds. if there is an @@ -3532,10 +3566,10 @@ { if (bigUpdate()) { // Try again later. - gtk_timeout_add(2*60*1000, bigdelay_callback, NULL); + g_timeout_add(2*60*1000, bigdelay_callback, NULL); DPRINTF(DHIGH, ("Next bigUpdate() in 2 minutes.\n")); } else { - gtk_timeout_add(BIGDELAY, bigdelay_callback, NULL); + g_timeout_add(BIGDELAY, bigdelay_callback, NULL); DPRINTF(DHIGH, ("Next bigUpdate() in %i minutes.\n", BIGDELAY/60/1000)); } @@ -3550,24 +3584,16 @@ { int minTimeLeft; - int time_to_next_update; - int max_update; - - if (aucIdx == 0) { - gtk_timeout_add(30*60*1000,updatelist_callback,NULL); - return FALSE; - } minTimeLeft = timeToNextEnd() - (int)((avg_load_time + 500)/1000); if (minTimeLeft > -2 && minTimeLeft < snipeDelay + 2) { // don't interfere with the snipe - gtk_timeout_add((minTimeLeft + 3) *1000,updatelist_callback,NULL); + g_timeout_add((minTimeLeft + 3) *1000,updatelist_callback,NULL); return FALSE; } if (updateInProgress) { - gtk_timeout_add(30*1000,updatelist_callback,NULL); return FALSE; } @@ -3582,32 +3608,7 @@ Update(4*60, FALSE); } updateInProgress = FALSE; - - minTimeLeft = timeToNextEnd() - (int)((avg_load_time + 500)/1000); - - if (minTimeLeft > 0 && minTimeLeft < snipeDelay + 2) - // don't interfere with the snipe - time_to_next_update = (minTimeLeft + 3) * 1000; - else if (minTimeLeft < 3*60) // watch it even closer - time_to_next_update = update_prio1_interval *1000; - else if (minTimeLeft < 15*60) // watch it closely - time_to_next_update = update_prio2_interval *1000; - else if (minTimeLeft < 2*60*60) // no sense in wasting bandwidth... - time_to_next_update = update_prio3_interval *1000; - else // *yawn* - time_to_next_update = update_prio4_interval *1000; - - max_update = (int)(avg_load_time * 2); - if (time_to_next_update < max_update) { -#ifdef DEBUG_NETWORK - fprintf(stderr, "poor network response: " - "Adjusting update time from %d to %d\n", - time_to_next_update, max_update); -#endif - time_to_next_update = max_update; - } - - gtk_timeout_add(time_to_next_update,updatelist_callback,NULL); + timeout1Up(); return FALSE; } @@ -4887,6 +4888,7 @@ makeStyles(); + timeout1Up(); init(); gtk_main(); |