条件変数を取得し、一定の時間間隔の後にそれを解放するユースケースがあります (例: 時間順のイベントのキューがあり、指定された期間ブロックしたい .)
Duration = Earliest Time in Q - Current Time()
私はまさに私の目的を果たす次のものに出くわしました。
pthread_cond_timedwait(pthread_cond_t *restrict cond,
pthread_mutex_t *restrict mutex,
const struct timespec *restrict abstime);
しかし、問題は timespec.sec が time_t (これは 32 符号付きの型) であり、オーバーフローすることです。これに対する回避策はありますか? より長い間ブロックする他の構成要素はありますか? Linux プラットフォームを使用しています。