Thread and Timer converted to class (#81)

This commit is contained in:
Ken Van Hoeylandt
2024-11-22 23:08:18 +01:00
committed by GitHub
parent 85e26636a3
commit 854fefa1a1
20 changed files with 550 additions and 679 deletions
+4 -4
View File
@@ -90,14 +90,14 @@ static int32_t gpio_task(void* context) {
static void task_start(Gpio* gpio) {
tt_assert(gpio->thread == nullptr);
lock(gpio);
gpio->thread = thread_alloc_ex(
gpio->thread = new Thread(
"gpio",
4096,
&gpio_task,
gpio
);
gpio->thread_interrupted = false;
thread_start(gpio->thread);
gpio->thread->start();
unlock(gpio);
}
@@ -107,10 +107,10 @@ static void task_stop(Gpio* gpio) {
gpio->thread_interrupted = true;
unlock(gpio);
thread_join(gpio->thread);
gpio->thread->join();
lock(gpio);
thread_free(gpio->thread);
delete gpio->thread;
gpio->thread = nullptr;
unlock(gpio);
}