ratio_pub.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. function ratio_update(&$quit)
  3. {
  4. //每分钟的第0秒 将上一分钟的数据,写入HD5File。
  5. //每分钟的第2秒 统计之前的数据
  6. //每分钟的第3秒触发更新 成功率统计数据
  7. $cur_min = 0;
  8. while (!$quit) {
  9. Log::record("ratio_update start calc quit =" . strbool($quit), Log::DEBUG);
  10. Log::record("ratio_update start sleep", Log::DEBUG);
  11. // Co::sleep(1);
  12. Swoole\Coroutine\System::sleep(1);
  13. // sleep(1);
  14. Log::record("ratio_update end sleep", Log::DEBUG);
  15. }
  16. }
  17. // for ($i = 0; $i < 61; $i++) {
  18. // $cur_time = time();
  19. // $time_sec = $cur_time;
  20. // $next_min = $time_sec - $time_sec % 60;
  21. //
  22. // if($quit) break;
  23. // if($next_min > $cur_min && $time_sec % 60 == 3) {
  24. // $cur_min = $next_min;
  25. // break;
  26. // } else {
  27. // Log::record("ratio_update start sleep",Log::DEBUG);
  28. // Swoole\Coroutine::sleep(1);
  29. // Log::record("ratio_update end sleep",Log::DEBUG);
  30. // }
  31. // }
  32. // if(!$quit) {
  33. // refill\RefillFactory::instance()->UpdateRatio();
  34. // }
  35. // }
  36. //
  37. // Log::record("ratio_update quit =". strbool($quit),Log::DEBUG);
  38. // $quit = true;
  39. //}