EmotiBit / ofxEmotiBit

OpenFrameworks library and examples for the EmotiBit
MIT License
33 stars 7 forks source link

Add thread sleep delay timing control to emotibitCommSettings #227

Open produceconsumerobot opened 5 months ago

produceconsumerobot commented 5 months ago

Plan:

File input

emotibitCommSettings.json>wifi>advertising>threadSleep_usec emotibitCommSettings.json>wifi>data>threadSleep_usec

Code logic

If (threadSleep < 0) { // do nothing, not even yield } else if (threadSleep == 0) { std::this_thread::yield(); } else { std::this_thread::sleep_for(threadSleep) }

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.

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.

https://stackoverflow.com/questions/17325888/c11-thread-waiting-behaviour-stdthis-threadyield-vs-stdthis-thread

Additional code changes

Move parsing of emotibitCommSettings.json into EmotiBitWiFiHost

produceconsumerobot commented 4 months ago

Testing from within VS:

image image

image

image

image

image

image

image

image

Testing from exe

image image image image

produceconsumerobot commented 4 months ago

Tests to run

Independent variables

Basic tests

Dependent variables

produceconsumerobot commented 4 months ago

ToDo: