mirror of
https://github.com/ByteWelder/Tactility.git
synced 2026-02-18 10:53:17 +00:00
- 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`
35 lines
709 B
C++
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();
|
|
}
|