Ticket #25979

マルチコア レンダラの xlib 対応(その他)

Date d'ouverture: 2011-08-11 17:18 Dernière mise à jour: 2011-08-12 09:25

Rapporteur:
Propriétaire:
État:
Atteints
Priorité:
5 - moyen
Sévérité:
5 - moyen
Résolution:
Aucun
Fichier:
Aucun

Détails

その他すべての Win32API の X API ポーティング(Linux 対応)

  • タイマー処理
  • プロセッサ情報取得
  • その他 windows.h 依存箇所の排除

―――まだまだ結構ありました。

Ticket History (3/3 Histories)

2011-08-11 17:18 Updated by: chiharunpo
  • New Ticket "マルチコア レンダラの xlib 対応(その他)" created
2011-08-11 18:19 Updated by: chiharunpo
Commentaire

タイマー処理

usleep を使用する方法も検討しましたが、カーネル オブジェクトで待機することを明示するために select を使用することにしました。

  1. inline void sleep(const std::uint32_t iTime)
  2. {
  3. const auto aSec = iTime / 1000;
  4. const auto aMsec = iTime - aSec * 1000;
  5. timeval aTime;
  6. aTime.tv_sec = aSec;
  7. aTime.tv_usec = aMsec * 1000;
  8. select(0, nullptr, nullptr, nullptr, &aTime);
  9. }
  10. inline const std::uint32_t getTime()
  11. {
  12. timeval aTime;
  13. gettimeofday(&aTime, nullptr);
  14. return aTime.tv_sec * 1000 + aTime.tv_usec / 1000;
  15. }

プロセッサ情報の取得

ワンライナーでプロセッサ情報を標準出力するコマンドをパイプでつなげました。

  1. inline const std::uint32_t getProcessors()
  2. {
  3. auto aProcessors = 0;
  4. // プロセッサ数取得
  5. if (auto aPipe = popen("egrep -c \"^processor\\s:\\s[0-9]+$\" /proc/cpuinfo", "r")) {
  6. char aStr[512];
  7. if (std::fgets(aStr, sizeof(aStr), aPipe)) {
  8. aProcessors = std::atoi(aStr);
  9. }
  10. pclose(aPipe);
  11. }
  12. // エラー処理
  13. if (aProcessors == 0) {
  14. aProcessors = 1;
  15. }
  16. return aProcessors;
  17. }

2011-08-12 09:25 Updated by: chiharunpo
  • État Update from Ouvert to Atteints
  • Ticket Close date is changed to 2011-08-12 09:25
Commentaire

フォント処理以外の Win32API 依存処理をひととおり分離しました。

Attachment File List

No attachments

Modifier

Please login to add comment to this ticket » Connexion