Multithreading – STD:: this_ Thread:: yield() usage?
•
Java
Can someone provide STD:: this in C application_ A real example of the use of thread:: yield()?
Solution
I used yield in the implementation of STD:: lock. Here I find:
http://llvm.org/svn/llvm-project/libcxx/trunk/include/mutex
It has been proved that when multiple locks / mutexes are locked at one time, if one lock / mutex is not obtained, you can use yield to speed up the application before trying locks / mutexes in different order
In this source code, I'm actually calling sched_ yield(). But this is just to get the header dependency the way I want On this platform, STD:: this_ Thread:: yield() is just a reference to sched_ Call to yield():
http://llvm.org/svn/llvm-project/libcxx/trunk/include/thread
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码