std::thread implementation for ESP32 to Arduino API/IDE
Multithreading on Arduino/esp
Multi-threading with the ESP32 - Projects made with Blynk - Blynk Community
Multithreading avec un ESP32
Videos
It's really difficult to chase down race conditions, even with a debugger.
Because of that, you may hesitate to use the secondary core on applicable ESP32s.
I've created a PlatformIO library to make it almost foolproof to write code that targets the secondary core or just a secondary thread on the primary core.
The library is easy to use and examples are included.
Add this to your platformio.ini
lib_ldf_mode = deep lib_deps = codewitch-honey-crisis/htcw_freertos_thread_pack
Or visit this link to download the code manually (necessary if using Arduino IDE)
https://github.com/codewitch-honey-crisis/htcw_freertos_thread_pack
Included is a thread class, a thread pool class, a thread safe message queue class, and something called a "synchronization_context". The latter was a concept I "borrowed" from .NET that allows you to dispatch code on a waiting thread. Basically you feed it a lambda from the primary thread and it will run whatever code was inside of it on the thread that's waiting. It often makes it unnecessary to roll your own synchronization.
Examples are included under /examples
Are there any ESP32 devices which support thread (matter)? And in addition, are there any libraries like homespan which can be used for building such a device to be used with apple HomeKit?