VirtualBox

Changeset 35831 in vbox


Ignore:
Timestamp:
Feb 3, 2011 11:34:45 AM (14 years ago)
Author:
vboxsync
Message:

VBoxManage guestcontrol execute --wait-for: adaptive sleep to prevent busy waiting

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManageGuestCtrl.cpp

    r35747 r35831  
    492492                BOOL fCompleted = FALSE;
    493493                BOOL fCanceled = FALSE;
     494                int cMilliesSleep = 0;
    494495                while (SUCCEEDED(progress->COMGETTER(Completed(&fCompleted))))
    495496                {
     
    575576                        break;
    576577                    }
     578
     579                    /* Don't hog the CPU in a busy loop! */
     580                    if (cbOutputData <= 0)
     581                    {
     582                        if (cMilliesSleep < 100)
     583                            cMilliesSleep++;
     584                        RTPrintf("cMilliesSleep = %d\n", cMilliesSleep);
     585                        RTThreadSleep(cMilliesSleep);
     586                    }
     587                    else
     588                        cMilliesSleep = 0;
    577589                }
    578590
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette