lundi 27 mai 2019

Which is the best way to yield thread?

Program language: C++ 11
I use pipeline threads mode to deal data.
One thread generate data.
One thread process data.
While no data to deal, which is the best way to yield thread?
Now I use

std::this_thread::sleep_for(100ms); 

  1. I wonder if there is a better way to yield?
  2. If sleep is well enough, how long time to sleep is better?

Aucun commentaire:

Enregistrer un commentaire