Ken Van Hoeylandt 43c78c69d8
Thread, Timer and flash.sh improvements (#165)
- Various improvements to Thread and Timer:
  - Remove "mark as static" option as it is unused
  - Implemented core pinning for ESP32 platforms
  - Use `TickType_t` consistently (instead of `uint32_t`)
  - Use `enum class` instead of `enum`
- Fix for `flash.sh` not working when using `pip` to install `esptool`
2025-01-13 20:20:43 +01:00

35 lines
709 B
C++

#include "doctest.h"
#include "TactilityCore.h"
#include "Mutex.h"
using namespace tt;
static int32_t thread_with_mutex_parameter(void* parameter) {
auto* mutex = (Mutex*)parameter;
mutex->lock(portMAX_DELAY);
return 0;
}
TEST_CASE("a mutex can block a thread") {
auto mutex = Mutex(Mutex::TypeNormal);
mutex.lock(portMAX_DELAY);
Thread thread = Thread(
"thread",
1024,
&thread_with_mutex_parameter,
&mutex
);
thread.start();
kernel::delayMillis(5);
CHECK_EQ(thread.getState(), Thread::State::Running);
mutex.unlock();
kernel::delayMillis(5);
CHECK_EQ(thread.getState(), Thread::State::Stopped);
thread.join();
}