1

refactor main menu

This commit is contained in:
2022-07-17 01:16:09 +02:00
parent 9a0bb01c6d
commit 931c9552b7

View File

@ -27,9 +27,9 @@ void MainMenu::run() {
char input = '\0';
Thread* choosen_demo = NULL;
while (true) {
input = this->listener.waitForKeyEvent();
if (choosen_demo == NULL) {
switch (input) {
case '1':
choosen_demo = new TextDemo();
@ -52,20 +52,21 @@ void MainMenu::run() {
case '7':
choosen_demo = new PreemptiveThreadDemo(3);
break;
case 'k':
if (choosen_demo != NULL) {
scheduler.kill(choosen_demo);
delete choosen_demo;
choosen_demo = NULL;
}
kout.clear();
print_demo_menu();
break;
}
if (choosen_demo != NULL) {
// We actually chose something
scheduler.ready(choosen_demo);
}
} else if (input == 'k') {
scheduler.kill(choosen_demo); // NOTE: If thread exits itself this will throw error
choosen_demo = NULL;
kout.clear();
print_demo_menu();
}
input = '\0';
}
// Extra demos