Changeset 1570


Ignore:
Timestamp:
Jun 13, 2011, 12:09:19 AM (14 years ago)
Author:
Gregg Young
Message:

Added IdleIfNeeded to place load and free loops to idle priority when dealing with large numbers of items. Used SleepIfNeeded more places for a similar purpose.

Location:
trunk/dll
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/dll/common.c

    r1498 r1570  
    150150  case UM_RESCAN:
    151151    if (fAutoTile &&
    152         !fAmClosing && !fNoTileUpdate && !ParentIsDesktop(hwnd, (HWND) 0))
     152        !fAmClosing && !fNoTileUpdate && !ParentIsDesktop(hwnd, (HWND) 0))
    153153      PostMsg(WinQueryWindow(hwnd, QW_PARENT), UM_RESCAN, MPVOID, MPVOID);
    154154    return 0;
  • trunk/dll/comp.c

    r1563 r1570  
    7676  23 Oct 10 GKY Add ForwardslashToBackslash function to streamline code
    7777  29 May 11 SHL Rework >65K records logic - prior fix was not quite right
     78  12 Jun 11 GKY Added SleepIfNeeded in the container fill loop
    7879
    7980***********************************************************************/
     
    13431344  APIRET rc;
    13441345  static BOOL fDone;
     1346  ITIMER_DESC itdSleep = { 0 };         // 30 May 11 GKY
    13451347
    13461348  if (!str || !*str) {
     
    13761378                     pffbArray, ulBufBytes, &ulFindCnt, FIL_QUERYEASIZEL);
    13771379  if (!rc) {
     1380    InitITimer(&itdSleep, 500);
    13781381    do {
    13791382      pffbFile = pffbArray;
     
    14231426      ulFindCnt = FilesToGet;
    14241427      rc = xDosFindNext(hDir, pffbArray, ulBufBytes, &ulFindCnt, FIL_QUERYEASIZEL);
     1428      SleepIfNeeded(&itdSleep, 1);
    14251429    } while (!rc);
    14261430
  • trunk/dll/dircnrs.c

    r1553 r1570  
    14121412          //DosEnterCritSec(); //GKY 11-27-08
    14131413          dcd->stopflag++;
    1414           //DosExitCritSec();
     1414          //DosExitCritSec();
     1415          //DbgMsg(pszSrcFile, __LINE__, "WM_RESCAN");
    14151416          if (!PostMsg(dcd->hwndObject, UM_RESCAN, MPVOID, MPFROMLONG(1L))) {
    14161417            strcpy(dcd->directory, dcd->previous);
     
    14681469      WinSetDlgItemText(dcd->hwndClient, DIR_SELECTED, s);
    14691470      if (hwndStatus &&
    1470           dcd->hwndFrame == WinQueryActiveWindow(dcd->hwndParent)) {
     1471          dcd->hwndFrame == WinQueryActiveWindow(dcd->hwndParent)) {
    14711472        PostMsg(dcd->hwndObject, UM_RESCAN2, MPVOID, MPVOID);
    14721473        if ((fSplitStatus && hwndStatus2) || fMoreButtons) {
     
    23132314        //DosEnterCritSec(); //GKY 11-27-08
    23142315        dcd->stopflag++;
    2315         //DosExitCritSec();
     2316        //DosExitCritSec();
     2317        //DbgMsg(pszSrcFile, __LINE__, "WM_RESCAN");
    23162318        if (!PostMsg(dcd->hwndObject, UM_RESCAN, MPVOID, MPVOID)) {
    23172319          //DosEnterCritSec(); //GKY 11-27-08
     
    24512453          //DosEnterCritSec(); // GKY 11-27-08
    24522454          dcd->stopflag++;
    2453           //DosExitCritSec();
     2455          //DosExitCritSec();
     2456          //DbgMsg(pszSrcFile, __LINE__, "WM_RESCAN");
    24542457          if (!PostMsg(dcd->hwndObject, UM_RESCAN, MPVOID, MPFROMLONG(1L))) {
    24552458            strcpy(dcd->directory, dcd->previous);
     
    24742477          strcpy(tempname1, dcd->directory);
    24752478          AddBackslashToPath(tempname1);
    2476           //if (tempname1[strlen(tempname1) - 1] != '\\')
    2477           //  strcat(tempname1, "\\");
    24782479          strcat(tempname1, "..");
    24792480          DosError(FERR_DISABLEHARDERR);
     
    24842485              strcpy(dcd->previous, dcd->directory);
    24852486              strcpy(dcd->directory, tempname2);
    2486               //DosEnterCritSec(); // GKY 11-27-08
    24872487              dcd->stopflag++;
    2488               //DosExitCritSec();
     2488              //DbgMsg(pszSrcFile, __LINE__, "WM_RESCAN");
    24892489              if (!PostMsg(dcd->hwndObject,
    24902490                           UM_RESCAN, MPVOID, MPFROMLONG(1L))) {
    24912491                strcpy(dcd->directory, dcd->previous);
    2492                 //DosEnterCritSec();// GKY 11-27-08
    24932492                dcd->stopflag--;
    2494                 //DosExitCritSec();
    24952493              }
    24962494              else if (*dcd->directory) {
     
    25162514            strcpy(dcd->directory, dcd->previous);
    25172515            strcpy(dcd->previous, tempname);
    2518             //DosEnterCritSec(); // GKY 11-27-08
    2519             dcd->stopflag++;
    2520             //DosExitCritSec();
     2516            dcd->stopflag++; ;
     2517            //DbgMsg(pszSrcFile, __LINE__, "WM_RESCAN");
    25212518            if (!PostMsg(dcd->hwndObject, UM_RESCAN, MPVOID, MPFROMLONG(1L))) {
    25222519              strcpy(dcd->directory, dcd->previous);
    2523               //DosEnterCritSec(); // GKY 11-27-08
    25242520              dcd->stopflag--;
    2525               //DosExitCritSec();
    25262521            }
    25272522            else if (*dcd->directory) {
     
    25532548            strcpy(dcd->previous, dcd->directory);
    25542549            strcpy(dcd->directory, newdir);
    2555             //DosEnterCritSec(); //GKY 11-27-08
    25562550            dcd->stopflag++;
    2557             //DosExitCritSec();
     2551            //DbgMsg(pszSrcFile, __LINE__, "WM_RESCAN");
    25582552            if (!PostMsg(dcd->hwndObject, UM_RESCAN, MPVOID, MPFROMLONG(1L))) {
    25592553              strcpy(dcd->directory, dcd->previous);
    2560               //DosEnterCritSec(); // GKY 11-27-08
    25612554              dcd->stopflag--;
    2562               //DosExitCritSec();
    25632555            }
    25642556            else if (*dcd->directory) {
     
    33993391                  strcpy(dcd->previous, dcd->directory);
    34003392                  strcpy(dcd->directory, pci->pszFileName);
    3401                   //DosEnterCritSec();  // GKY 11-27-08
    34023393                  dcd->stopflag++;
    3403                   //DosExitCritSec();
     3394                  //DbgMsg(pszSrcFile, __LINE__, "WM_RESCAN");
    34043395                  if (!PostMsg(dcd->hwndObject,
    34053396                               UM_RESCAN, MPVOID, MPFROMLONG(1))) {
    3406                     //DosEnterCritSec();  // GKY 11-27-08
    34073397                    dcd->stopflag--;
    3408                     //DosExitCritSec();
    34093398                  }
    34103399                  else if (*dcd->directory) {
     
    34463435              }
    34473436              else {
    3448                 //DosEnterCritSec();  // GKY 11-27-08
    34493437                dcd->stopflag++;
    3450                 //DosExitCritSec();
     3438                //DbgMsg(pszSrcFile, __LINE__, "WM_RESCAN");
    34513439                if (!PostMsg(dcd->hwndObject,
    34523440                             UM_RESCAN, MPVOID, MPFROMLONG(1L))) {
    3453                   //DosEnterCritSec(); // GKY 11-27-08
    34543441                  dcd->stopflag--;
    3455                   //DosExitCritSec();
    34563442                }
    34573443                else if (*dcd->directory) {
  • trunk/dll/dirsize.c

    r1554 r1570  
    5555  20 Nov 10 GKY Check that pTmpDir IsValid and recreate if not found; Fixes hangs caused
    5656                by temp file creation failures.
     57  12 Jun 11 GKY Added SleepIfNeeded in the container fill loop
    5758
    5859***********************************************************************/
     
    9697#include "excputil.h"                   // xbeginthread
    9798#include "pathutil.h"                   // AddBackslashToPath
     99#include "tmrsvcs.h"
    98100
    99101typedef struct
     
    267269    PFILEFINDBUF4L pffbFile;
    268270    ULONG x;
    269 
     271    ITIMER_DESC itdSleep = { 0 };               // 30 May 11 GKY
     272
     273    InitITimer(&itdSleep, 500);
    270274    while (!rc) {
    271275
     
    303307      DosError(FERR_DISABLEHARDERR);
    304308      rc = xDosFindNext(hdir, pffbArray, ulBufBytes, &ulFindCnt, FIL_QUERYEASIZEL);
     309      SleepIfNeeded(&itdSleep, 1);
    305310    } // while more found
    306311
  • trunk/dll/filldir.c

    r1567 r1570  
    9595  30 May 11 GKY Added SleepIfNeeded to DosFind and container load loops to improve WPS responsiveness
    9696  31 May 11 SHL Disable antique debug code in RemoveCnrItems - really speeds up container close
     97  12 Jun 11 GKY Added IdleIfNeeded to the container "free" loops to improve system
     98                responsiveness when closing containers with large numbers of items
     99  12 Jun 11 GKY Replaced SleepIfNeeded with IdleIfNeeded in the container loade loop
    97100
    98101***********************************************************************/
     
    986989                       &ulFindCnt,
    987990                       FIL_QUERYEASIZEL);
    988     //priority_normal();
     991    priority_normal();
    989992    pszFileSpec[strlen(pszFileSpec) - 1] = 0;   // Chop off wildcard
    990993    if (!rc) {
     
    11131116        ulFindCnt = ulFindMax;
    11141117        rc = xDosFindNext(hdir, paffbFound, ulBufBytes, &ulFindCnt, FIL_QUERYEASIZEL);
    1115         //priority_normal();
     1118        priority_normal();
    11161119        if (rc)
    11171120          DosError(FERR_DISABLEHARDERR);
     
    11301133          goto Abort;
    11311134
     1135        InitITimer(&itdSleep, 500);
    11321136        pci = NULL;
    11331137        ullTotalBytes = 0;
     
    11691173          pffbFile = (PFILEFINDBUF4L)((PBYTE)pffbFile + sizeof(FILEFINDBUF4L));
    11701174
     1175          if (!IdleIfNeeded(&itdSleep, 30)) {
     1176            for (x = x+1; x < cAffbTotal; x++) {
     1177              ullBytes = FillInRecordFromFFB(hwndCnr, pci, pszFileSpec,
     1178                                          pffbFile, partial, dcd);
     1179              pci = (PCNRITEM) pci->rc.preccNextRecord;
     1180              ullTotalBytes += ullBytes;
     1181              if (dcd) {
     1182                dcd->totalfiles = x;
     1183                dcd->ullTotalBytes = ullTotalBytes;
     1184              }
     1185              pffbFile = (PFILEFINDBUF4L)((PBYTE)pffbFile + sizeof(FILEFINDBUF4L));
     1186              if (pci == NULL) {
     1187                priority_normal();
     1188                InitITimer(&itdSleep, 500);
     1189                break;
     1190              }
     1191            }
     1192          }
     1193
    11711194          if (pci == NULL && ulRecsToInsert) {
    11721195            memset(&ri, 0, sizeof(RECORDINSERT));
     
    11951218            }
    11961219          }
    1197           SleepIfNeeded(&itdSleep, 1);
    1198         }
     1220          //SleepIfNeeded(&itdSleep, 1);
     1221        }
     1222        priority_normal();
    11991223        if (ok) {
    12001224          ullReturnBytes += ullTotalBytes;
     
    19852009    FreeCnrItemData(pci);
    19862010    pci = pciNext;
    1987     SleepIfNeeded(&itdSleep, 1);
    1988   }
    1989 
     2011    if (!IdleIfNeeded(&itdSleep, 30)) {
     2012      for (usCount = usCount + 1; pci; usCount++) {
     2013        pciNext = (PCNRITEM) pci->rc.preccNextRecord;
     2014        FreeCnrItemData(pci);
     2015        pci = pciNext;
     2016      }
     2017      break;
     2018    }
     2019  }
     2020  priority_normal();
     2021  DosPostEventSem(CompactSem);
    19902022  if (usCount) {
    19912023    if (!WinSendMsg(hwnd, CM_FREERECORD, MPFROMP(&pci), MPFROMSHORT(usCount))) {
     
    20452077        if (remaining && --remaining == 0)
    20462078          break;
    2047         SleepIfNeeded(&itdSleep, 1);
    2048       }
     2079        if (!IdleIfNeeded(&itdSleep, 30)) {
     2080          while (pci) {
     2081            FreeCnrItemData(pci);
     2082            pci = (PCNRITEM)pci->rc.preccNextRecord;
     2083            if (remaining && --remaining == 0)
     2084              break;
     2085          }
     2086        }
     2087      }
     2088      priority_normal();
     2089      DosPostEventSem(CompactSem);
    20492090    }
    20502091  }
  • trunk/dll/makelist.c

    r1210 r1570  
    1616  29 Feb 08 GKY Use xfree where appropriate
    1717  17 Jul 08 SHL Add SetListOwner for Fortify support
     18  12 Jun 11 GKY Added IdleIfNeeded to the freelist loop to improve system
     19                responsiveness when freeing lists with large numbers of items
    1820
    1921***********************************************************************/
     
    3638#include "wrappers.h"                   // xfree
    3739#include "fortify.h"                    // 06 May 08 SHL
     40#include "tmrsvcs.h"                    // ITIMER_DESC
    3841
    3942static PSZ pszSrcFile = __FILE__;
     
    8588{
    8689  UINT x;
    87 
     90  ITIMER_DESC itdSleep = { 0 };         
     91           
    8892  if (list) {
     93     InitITimer(&itdSleep, 500);
    8994    for (x = 0; list[x]; x++) {
    9095#ifdef __DEBUG_ALLOC__
     
    9297#endif
    9398      free(list[x]);
     99      if (!IdleIfNeeded(&itdSleep, 30)) {
     100        for (x = x + 1; list[x]; x++) {
     101          free(list[x]);
     102        }
     103        break;
     104      }
    94105    }
    95106#ifdef __DEBUG_ALLOC__
     
    97108#endif
    98109    free(list);
    99   }
    100   DosPostEventSem(CompactSem);
     110    priority_normal();
     111    DosPostEventSem(CompactSem);
     112  }
    101113}
    102114
  • trunk/dll/tmrsvcs.c

    r1521 r1570  
    99
    1010  05 Jan 08 SHL Baseline
     11  12 Jun 11 GKY Added IdleIfNeeded to the container/list fill and free loops to improve system
     12                responsiveness when dealing with large numbers of items
    1113
    1214***********************************************************************/
     
    107109}
    108110
    109 #pragma alloc_text(TMRSVCS,InitITimer,IsITimerExpired,SleepIfNeeded)
     111ULONG IdleIfNeeded(ITIMER_DESC *pitd, LONG delta)
     112{
     113  APIRET rc;
     114
     115  if (IsITimerExpired(pitd)) {
     116    rc = DosSetPriority(PRTYS_THREAD,PRTYC_IDLETIME,delta,0L);
     117    InitITimer(pitd, 0);
     118    return rc;
     119  }
     120  return 1;
     121}
     122
     123#pragma alloc_text(TMRSVCS,InitITimer,IsITimerExpired,SleepIfNeeded,IdleIfNeeded)
  • trunk/dll/tmrsvcs.h

    r1201 r1570  
    3030BOOL IsITimerExpired(ITIMER_DESC *pitd);
    3131VOID SleepIfNeeded(ITIMER_DESC *pitd, UINT sleepTime);
     32ULONG IdleIfNeeded(ITIMER_DESC *pitd, LONG delta);
    3233
    3334#endif // TMRSVCS_H
  • trunk/dll/treecnr.c

    r1561 r1570  
    878878      WinSendMsg(dcd->hwndCnr,
    879879                 CM_INVALIDATERECORD,
    880                 MPVOID, MPFROM2SHORT(0, CMA_ERASE | CMA_REPOSITION));
     880                MPVOID, MPFROM2SHORT(0, CMA_ERASE | CMA_REPOSITION));
    881881      PostMsg(dcd->hwndCnr, UM_RESCAN, MPVOID, MPVOID);
    882882    }
Note: See TracChangeset for help on using the changeset viewer.