Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
thread::maybe_yield, a static method, calls into thread_impl::maybe_yield which is a member function on the current thread context, which means we need to access the TLS etc, but this function is itself essentially static as it only calls needs_prempt(). This was probably different in the ancient past where there were thread-specific scheduling groups, etc. This method is performance sensitive as it is often called in loops, even tight loops as it is often difficult to call it less frequently in a tight loop which may have a large trip count. Therefore it is worth optimizing. So this change: - Have thread::maybe_yield just call needs_prempt() directly - Move maybe_yield and should_yield in to the header. This latter change doesn't change needed includes, so shouldn't impact compile time. The yield() function itself is still out-of-line. This provides a chance for the compile to hoist the TLS access boilerplate out of loops.
- Loading branch information