简体   繁体   中英

C++ equivalent of C# SpinWait.SpinUntil

I am in the need of spinning a thread until a specific condition appears.

In c# I had good experience with SpinWait .

However being somewhat new to C++ I am unsure what the equivalent to this would be:

    SpinWait.SpinUntil(() => myCondition == true);

I tried sleeping, yielding and looping without any but I cannot get the same performance in my C++ application that I had with c# SpinWait.

I am using VS 2017 and the VC++ compiler.

Using synchronization objects like events is what you are looking for. Just attach yourself to an event and setevent from where you are want to back again.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM