improvenments to threading

This commit is contained in:
nova
2025-06-24 00:18:53 +02:00
parent 1a64b83703
commit 36ff54038e
2 changed files with 12 additions and 20 deletions

24
main.c
View File

@ -53,27 +53,23 @@ int main(){
temp_width = terminal_width;
temp_heigth = terminal_height;
}
if (status & STATUS_RUN_BACKEND || threading) {
if (status & STATUS_RUN_BACKEND) {
if (threading) {
/* temporary comment, somehow stops timing related crashes
pthread_cancel(thread_t);
pthread_cancel(thread_b);
pthread_cancel(thread_l);
pthread_cancel(thread_m);
pthread_cancel(thread_r);
*/
pthread_cancel(thread_b);
threading = 0;
status &= ~STATUS_RUN_BACKEND;
status &= ~STATUS_RELOAD_DIRECTORY;
status |= STATUS_UPDATE_SCREEN_0;
} else {
pthread_create(&thread_t, NULL, thread_top, win_t); /*top bar*/
pthread_create(&thread_b, NULL, thread_btm, win_b); /*bottom bar*/
pthread_create(&thread_m, NULL, thread_mid, win_m); /*parent_content slash win_l*/
pthread_create(&thread_l, NULL, thread_lft, win_l); /*current_content slash win_m*/
pthread_create(&thread_r, NULL, thread_rgt, win_r); /*child_content slash win_r*/
threading = 1;
}
pthread_create(&thread_t, NULL, thread_top, win_t); /*top bar*/
pthread_create(&thread_l, NULL, thread_lft, win_l); /*current_content slash win_m*/
pthread_create(&thread_m, NULL, thread_mid, win_m); /*parent_content slash win_l*/
pthread_create(&thread_r, NULL, thread_rgt, win_r); /*child_content slash win_r*/
pthread_create(&thread_b, NULL, thread_btm, win_b); /*bottom bar*/
threading = 1;
status &= ~(STATUS_RUN_BACKEND | STATUS_RELOAD_DIRECTORY);
status |= STATUS_UPDATE_SCREEN_0;
}
if ((input = getch())) {
user_interactions(&input, win_b);

View File

@ -71,13 +71,13 @@ void *thread_mid(void *data){
mid_content[selected_file_last].status &= ~FILE_STATUS_HOVER;
}
selected_file_last = selected_file_current;
pthread_mutex_unlock(&mutex_selection);
file_current.file_name = malloc(mid_content[selected_file_current].file_name_width + 1);
strcpy(file_current.file_name, mid_content[selected_file_current].file_name);
file_current.file_name_width = mid_content[selected_file_current].file_name_width;
file_current.file_size_bytes = mid_content[selected_file_current].file_size_bytes;
file_current.file_type = mid_content[selected_file_current].file_type;
pthread_mutex_unlock(&mutex_selection);
}
free(path);
@ -86,9 +86,6 @@ void *thread_mid(void *data){
}
void *thread_lft(void *data){
pthread_mutex_lock(&mutex_lft);
/*{{{*/
char *path;
if((path=getcwd(NULL, 0)) == NULL) {
@ -112,7 +109,6 @@ void *thread_lft(void *data){
}
free(path);
pthread_mutex_unlock(&mutex_lft);
/*}}}*/
pthread_exit(NULL);