now each thread can queue its own rendering
This commit is contained in:
41
threading.c
41
threading.c
@@ -46,6 +46,7 @@ unsigned long top_width;
|
||||
|
||||
extern unsigned int terminal_width;
|
||||
extern unsigned int status;
|
||||
volatile char render_queue[RENDER_QUEUE_BTM+1];
|
||||
extern char *global_path;
|
||||
|
||||
unsigned int btm_status;
|
||||
@@ -71,6 +72,7 @@ void *thread_mid(){
|
||||
char *path = malloc(strlen(global_path)+1);
|
||||
memcpy(path, global_path, strlen(global_path)+1);
|
||||
|
||||
|
||||
if (local_status & STATUS_RELOAD_DIRECTORY) {
|
||||
long index = mid_dir.current_file - mid_dir.file_list;
|
||||
|
||||
@@ -85,6 +87,8 @@ void *thread_mid(){
|
||||
} else { /* the hovered dir is empty */
|
||||
mid_dir.current_file = NULL;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
if (mid_dir.current_file > mid_dir.file_list + mid_dir.file_count - 1) {
|
||||
@@ -95,12 +99,14 @@ void *thread_mid(){
|
||||
}
|
||||
|
||||
/* rendering */
|
||||
render_queue[RENDER_QUEUE_MID] = 0;
|
||||
werase(win_m);
|
||||
if (mid_dir.file_count == 0) {
|
||||
mvwaddstr(win_m, 0, 0, "empty");
|
||||
} else {
|
||||
print_dir(win_m, 1, &mid_dir);
|
||||
}
|
||||
render_queue[RENDER_QUEUE_MID] = 1;
|
||||
|
||||
pthread_cond_signal(&cond_rgt);
|
||||
pthread_cond_signal(&cond_top);
|
||||
@@ -138,6 +144,7 @@ void *thread_lft(){
|
||||
char *path = malloc(strlen(global_path)+1);
|
||||
memcpy(path, global_path, strlen(global_path)+1);
|
||||
|
||||
render_queue[RENDER_QUEUE_LFT] = 0;
|
||||
if (strcmp(path, "/") != 0) {
|
||||
path[strrchr(path, '/')-path+1] = '\0';
|
||||
path[strrchr(path, '/')-path] = '\0';
|
||||
@@ -166,6 +173,8 @@ void *thread_lft(){
|
||||
/* rendering */
|
||||
werase(win_l);
|
||||
print_dir(win_l, 0, &lft_dir);
|
||||
render_queue[RENDER_QUEUE_LFT] = 1;
|
||||
|
||||
pthread_mutex_unlock(&mutex_lft);
|
||||
|
||||
free(path);
|
||||
@@ -200,6 +209,8 @@ void *thread_rgt(){
|
||||
|
||||
pthread_mutex_unlock(&mutex_mid);
|
||||
|
||||
render_queue[RENDER_QUEUE_RGT] = 0;
|
||||
werase(win_r);
|
||||
if (rgt_dir.current_file->permissions & S_IRUSR) {
|
||||
if (rgt_dir.current_file->file_type &= FILE_TYPE_DIR) {
|
||||
#if SETTINGS_UEBERZUG_IMAGE_PREVIEW != 0
|
||||
@@ -215,32 +226,22 @@ void *thread_rgt(){
|
||||
} else { /* the hovered dir is empty */
|
||||
rgt_dir.current_file = NULL;
|
||||
}
|
||||
print_dir(win_r, 0, &rgt_dir);
|
||||
|
||||
} else if ((status & STATUS_DELTA_TIME) != STATUS_DELTA_TIME && rgt_dir.file_count > 0) {
|
||||
|
||||
|
||||
free(rgt_buffer);
|
||||
rgt_buffer = preview_file(rgt_dir.current_file);
|
||||
rgt_dir.current_file->file_type |= FILE_TYPE_OPEN_FILE;
|
||||
|
||||
|
||||
|
||||
if (rgt_dir.current_file->file_type == FILE_TYPE_OPEN_FILE) {
|
||||
mvwaddnstr(win_r, 0, 0, rgt_buffer, (terminal_width/2) * terminal_width);
|
||||
} else if ((rgt_dir.current_file->permissions & S_IRUSR) == 0) {
|
||||
mvwaddstr(win_r, 0, 0, "not accessible");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* rendering */
|
||||
werase(win_r);
|
||||
wattroff(win_r, A_REVERSE);
|
||||
if (!rgt_dir.current_file) {
|
||||
mvwaddstr(win_r, 0, 0, "not accessible");
|
||||
}else if (rgt_dir.current_file->file_type == FILE_TYPE_OPEN_FILE) {
|
||||
mvwaddnstr(win_r, 0, 0, rgt_buffer, (terminal_width/2) * terminal_width);
|
||||
} else if ((rgt_dir.current_file->permissions & S_IRUSR) == 0) {
|
||||
mvwaddstr(win_r, 0, 0, "not accessible");
|
||||
} else {
|
||||
print_dir(win_r, 0, &rgt_dir);
|
||||
}
|
||||
|
||||
render_queue[RENDER_QUEUE_RGT] = 1;
|
||||
|
||||
pthread_mutex_unlock(&mutex_rgt);
|
||||
long i;
|
||||
@@ -261,6 +262,8 @@ void *thread_top(){
|
||||
pthread_mutex_lock(&mutex_top);
|
||||
pthread_cond_wait(&cond_top, &mutex_top);
|
||||
|
||||
|
||||
render_queue[RENDER_QUEUE_TOP] = 0;
|
||||
free(top_buffer);
|
||||
|
||||
if(global_path == NULL) {
|
||||
@@ -286,6 +289,7 @@ void *thread_top(){
|
||||
mvwaddstr(win_t, 0, strlen(top_buffer)+1, mid_dir.current_file->file_name);
|
||||
}
|
||||
}
|
||||
render_queue[RENDER_QUEUE_TOP] = 1;
|
||||
|
||||
|
||||
pthread_mutex_unlock(&mutex_top);
|
||||
@@ -303,6 +307,7 @@ void *thread_btm(){
|
||||
pthread_cond_wait(&cond_btm, &mutex_btm);
|
||||
unsigned int local_status = btm_status;
|
||||
|
||||
render_queue[RENDER_QUEUE_BTM] = 0;
|
||||
|
||||
if (local_status & (STATUS_RUN_BACKEND | STATUS_RELOAD_DIRECTORY)) {
|
||||
/*{{{ parse storage info; the fold of shame*/
|
||||
@@ -404,8 +409,8 @@ void *thread_btm(){
|
||||
if (*top_buffer != ' ') { /*printing ' ' (standard initialized value, see threading_init) makes valgrind throw a fuss*/
|
||||
mvwprintw(win_b, 0, 0, "%s", btm_buffer);
|
||||
}
|
||||
render_queue[RENDER_QUEUE_BTM] = 1;
|
||||
pthread_mutex_unlock(&mutex_btm);
|
||||
/*the printing of the input char is done in user_interactions*/
|
||||
/*the printing of all possible inputs are done in user_interactions */
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user