什么是子循环

What means sub-cycled?

本文关键字:循环 什么      更新时间:2023-10-16

在类Time的方法run()中,在以下代码中使用变量bool subCycling_:

       bool Foam::Time::run() const
  810 {
  811     bool running = value() < (endTime_ - 0.5*deltaT_);
  812 
  813     if (!subCycling_) //bool subCycling_; //- Is the time currently being sub-cycled?
  814     {
  815         // only execute when the condition is no longer true
  816         // ie, when exiting the control loop
  817         if (!running && timeIndex_ != startTimeIndex_)
  818         {
  819             // Note, end() also calls an indirect start() as required
  820             functionObjects_.end();
  821         }
  822     }
  823 
  824     if (running)
  825     {
  826         if (!subCycling_)
  827         {
  828             const_cast<Time&>(*this).readModifiedObjects();
  829 
  830             if (timeIndex_ == startTimeIndex_)
  831             {
  832                 functionObjects_.start();
  833             }
  834             else
  835             {
  836                 functionObjects_.execute();
  837             }
  838         }
  839 
  840         // Update the "running" status following the
  841         // possible side-effects from functionObjects
  842         running = value() < (endTime_ - 0.5*deltaT_);
  843     }
  844 
  845     return running;
  846 }
  847 
  848 
  849 bool Foam::Time::loop()
  850 {
  851     bool running = run();
  852 
  853     if (running)
  854     {
  855         operator++();
  856     }
  857 
  858     return running;
  859 }

当我把sub-cycled翻译成德语时,我仍然不明白它的意思。那么,什么是子循环[第813行]?举个例子就很好了。

问候streight

您必须询问编写代码的人员。在没有任何上下文的情况下,不可能从这个微小的代码片段中随机分辨出来。在后面的行中可能有一个提示(因为这些行受这个布尔值的影响),但您没有向我们展示这些。

然而,作为线索,一些定时器实现使用"子周期"来描述在主事件循环的每个周期内运行定时器机制的重复迭代。这可以解决由个别等待条件引起的争用:

  • http://tams-www.informatik.uni-hamburg.de/applets/hades/webdemos/72-pic/60-swatch/swatch.html
  • http://nute.googlecode.com/svn/trunk/Lockets/Tears/tears_fmw/main.cpp
  • http://www.google.com/patents/US2530622

它更常见于运行机械设备的代码中。