続boost::xtime

Threadで思い出した小ネタ。
id:y-hamigaki:20060208 でxtimeを操作する関数を紹介したのですが、実はそういう関数群は、libs/thread/src/timeconv.inlに書いてあります。なんでこれをヘッダで公開していないのかずっと疑問だったのですが、ちゃんとドキュメントに書いてありました。

Note that the resolution is implementation specific. For many implementations the best resolution of time is far more than one nanosecond, and even when the resolution is reasonably good, the latency of a call to xtime_get() may be significant. For maximum portability, avoid durations of less than one second.

だそうです。精度はプラットフォーム依存だけど、sleep()やtimed_wait()の間隔は1秒以上にしてね、と。(1秒未満だと0秒扱いになって、無限ループの恐れあり)
う〜ん、でもこれなら1.1秒とかならいいわけで、秒未満のメンバを弄らせない理由にはならないような。安全策といえばそれまでなんですけど。