If (threadSleep < 0)
{
// do nothing, not even yield
}
else if (threadSleep == 0)
{
std::this_thread::yield();
}
else
{
std::this_thread::sleep_for(threadSleep)
}
Thread.Yield() allows another thread to run on the current processor while Thread.Sleep(0) allows another thread of equal priority to run, or keeps on the current thread. Thread.Sleep(1) allows the operating system to select the next thread to run.
Plan:
File input
emotibitCommSettings.json>wifi>advertising>threadSleep_usec emotibitCommSettings.json>wifi>data>threadSleep_usec
Code logic
Addl info
https://www.quora.com/What-is-the-difference-between-sleep-0-and-sched_yield#:~:text=Yield()%20allows%20another%20thread,the%20next%20thread%20to%20run.
https://stackoverflow.com/questions/17325888/c11-thread-waiting-behaviour-stdthis-threadyield-vs-stdthis-thread
Additional code changes
Move parsing of emotibitCommSettings.json into EmotiBitWiFiHost