マルチコア レンダラの xlib 対応(その他)
usleep を使用する方法も検討しましたが、カーネル オブジェクトで待機することを明示するために select を使用することにしました。
- inline void sleep(const std::uint32_t iTime)
- {
- const auto aSec = iTime / 1000;
- const auto aMsec = iTime - aSec * 1000;
- timeval aTime;
- aTime.tv_sec = aSec;
- aTime.tv_usec = aMsec * 1000;
- select(0, nullptr, nullptr, nullptr, &aTime);
- }
- inline const std::uint32_t getTime()
- {
- timeval aTime;
- gettimeofday(&aTime, nullptr);
- return aTime.tv_sec * 1000 + aTime.tv_usec / 1000;
- }
ワンライナーでプロセッサ情報を標準出力するコマンドをパイプでつなげました。
- inline const std::uint32_t getProcessors()
- {
- auto aProcessors = 0;
- // プロセッサ数取得
- if (auto aPipe = popen("egrep -c \"^processor\\s:\\s[0-9]+$\" /proc/cpuinfo", "r")) {
- char aStr[512];
- if (std::fgets(aStr, sizeof(aStr), aPipe)) {
- aProcessors = std::atoi(aStr);
- }
- pclose(aPipe);
- }
- // エラー処理
- if (aProcessors == 0) {
- aProcessors = 1;
- }
- return aProcessors;
- }
フォント処理以外の Win32API 依存処理をひととおり分離しました。
その他すべての Win32API の X API ポーティング(Linux 対応)
―――まだまだ結構ありました。