Logo Search packages:      
Sourcecode: ultracopier version File versions  Download package

void copyThread::setMaxSpeed ( int  tempMaxSpeed ) [slot]

Set the max speed.

Parameters:
tempMaxSpeedSet the max speed in KB/s, 0 for no limit

Definition at line 893 of file CopyThread.cpp.

References blockSizeCurrent, clockForTheCopySpeed, maxSpeed, MultForBigSpeed, and theCurrentStat.

Referenced by Main_window::abstractLayerGetSpeed(), and setBlockSize().

{
      if(tempMaxSpeed>=0)
      {
            if(maxSpeed==0 && tempMaxSpeed==0 && waitNewClockForSpeed.available()>0)
                  waitNewClockForSpeed.tryAcquire(waitNewClockForSpeed.available());
            maxSpeed=tempMaxSpeed;
            DEBUGCONSOLE(50,"copyThread::setMaxSpeed",QString("tempMaxSpeed=")+QString::number(tempMaxSpeed));
            if(maxSpeed>0)
            {
                  int NewInterval,newMultForBigSpeed=0;
                  do
                  {
                        newMultForBigSpeed++;
                        NewInterval=(blockSizeCurrent*newMultForBigSpeed)/(maxSpeed);
                  }
                  while (NewInterval<MINTIMERINTERVAL);
                  if(NewInterval>MAXTIMERINTERVAL)
                  {
                        NewInterval=MAXTIMERINTERVAL;
                        newMultForBigSpeed=1;
                        blockSizeCurrent=maxSpeed*NewInterval;
                  }
                  MultForBigSpeed=newMultForBigSpeed;
                        clockForTheCopySpeed.setInterval(NewInterval);
                  DEBUGCONSOLE(90,"copyThread::setMaxSpeed","setInterval at: "+QString::number(NewInterval)+"ms for "+QString::number(MultForBigSpeed)+" block(s) of "+QString::number(blockSizeCurrent)+"B.");
                  DEBUGCONSOLE(90,"copyThread::setMaxSpeed","for speed of: "+QString::number(((blockSizeCurrent*MultForBigSpeed)/NewInterval))+"KB/s");
                  if(!clockForTheCopySpeed.isActive() && theCurrentStat!=Stopped)
                        clockForTheCopySpeed.start();
            }
            else
            {
                  if(clockForTheCopySpeed.isActive())
                        clockForTheCopySpeed.stop();
                  waitNewClockForSpeed.release();
            }
      }
}

Here is the caller graph for this function:


Generated by  Doxygen 1.6.0   Back to index