1
0
mirror of https://gittea.dev/nova/th.git synced 2025-10-22 02:40:15 -04:00

removed the recreation and destruction of threads

This commit is contained in:
nova
2025-08-23 21:44:03 +02:00
parent a0a102e5f6
commit 963a018419
2 changed files with 208 additions and 185 deletions

27
main.c
View File

@@ -59,6 +59,11 @@ int main(){
char threading = 0;
terminal_width_empty_line = malloc(terminal_width);
pthread_create(&thread_t, NULL, thread_top, &status); /*top bar*/
pthread_create(&thread_l, NULL, thread_lft, &status); /*parent_content slash win_l*/
pthread_create(&thread_m, NULL, thread_mid, &status); /*current_content slash win_m*/
pthread_create(&thread_r, NULL, thread_rgt, &status); /*child_content slash win_r*/
pthread_create(&thread_b, NULL, thread_btm, &status); /*bottom bar*/
while(!(status & STATUS_QUIT_PROGRAM)){
getmaxyx(stdscr, terminal_height, terminal_width);
@@ -68,28 +73,16 @@ int main(){
temp_width = terminal_width;
temp_heigth = terminal_height;
}
if (status & STATUS_RUN_BACKEND && threading) {
pthread_cancel(thread_b);
pthread_cancel(thread_r);
pthread_cancel(thread_m);
pthread_cancel(thread_l);
pthread_cancel(thread_t);
}
if (threading) {
status &= ~(STATUS_RELOAD_DIRECTORY);
pthread_join(thread_t, NULL);
pthread_join(thread_l, NULL);
pthread_join(thread_m, NULL);
pthread_join(thread_b, NULL);
pthread_join(thread_r, NULL);
threading = 0;
}
if (status & STATUS_RUN_BACKEND) {
pthread_create(&thread_t, NULL, thread_top, &status); /*top bar*/
pthread_create(&thread_l, NULL, thread_lft, &status); /*parent_content slash win_l*/
pthread_create(&thread_m, NULL, thread_mid, &status); /*current_content slash win_m*/
pthread_create(&thread_b, NULL, thread_btm, &status); /*bottom bar*/
pthread_create(&thread_r, NULL, thread_rgt, &status); /*child_content slash win_r*/
pthread_cond_signal(&cond_top);
pthread_cond_signal(&cond_lft);
pthread_cond_signal(&cond_mid);
pthread_cond_signal(&cond_rgt);
pthread_cond_signal(&cond_btm);
status &= ~(STATUS_RUN_BACKEND);
status |= STATUS_UPDATE_SCREEN_0;
threading = 1;