Changeset c77cfd8 in mainline
- Timestamp:
- 2022-10-04T19:55:25Z (2 years ago)
- Branches:
- master, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- e0e612b
- Parents:
- 3fd38b2
- Location:
- uspace/app/taskbar
- Files:
-
- 3 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/taskbar/clock.c
r3fd38b2 rc77cfd8 89 89 } 90 90 91 fibril_mutex_initialize(&clock->lock); 92 fibril_condvar_initialize(&clock->timer_done_cv); 91 93 fibril_timer_set(clock->timer, 1000000, taskbar_clock_timer, clock); 92 94 … … 106 108 void taskbar_clock_destroy(taskbar_clock_t *clock) 107 109 { 110 /* 111 * Signal to the timer that we are cleaning up. If the timer handler 112 * misses it and sets the timer again, we will clear that active 113 * timer and be done (and if we were even slower and the timer 114 * fired again, it's the same situation as before. 115 */ 116 fibril_mutex_lock(&clock->lock); 117 clock->timer_cleanup = true; 118 fibril_mutex_unlock(&clock->lock); 119 120 /* If we catch the timer while it's active, there's nothing to do. */ 121 if (fibril_timer_clear(clock->timer) != fts_active) { 122 /* Need to wait for timer handler to finish */ 123 fibril_mutex_lock(&clock->lock); 124 while (clock->timer_done == false) 125 fibril_condvar_wait(&clock->timer_done_cv, &clock->lock); 126 fibril_mutex_unlock(&clock->lock); 127 } 128 108 129 fibril_timer_destroy(clock->timer); 109 130 ui_control_delete(clock->control); … … 302 323 taskbar_clock_t *clock = (taskbar_clock_t *) arg; 303 324 325 fibril_mutex_lock(&clock->lock); 304 326 (void) taskbar_clock_paint(clock); 305 fibril_timer_set(clock->timer, 1000000, taskbar_clock_timer, clock); 327 328 if (!clock->timer_cleanup) { 329 fibril_timer_set(clock->timer, 1000000, taskbar_clock_timer, 330 clock); 331 } else { 332 /* Acknowledge timer cleanup */ 333 clock->timer_done = true; 334 fibril_condvar_signal(&clock->timer_done_cv); 335 } 336 337 fibril_mutex_unlock(&clock->lock); 306 338 } 307 339 -
uspace/app/taskbar/meson.build
r3fd38b2 rc77cfd8 33 33 'taskbar.c', 34 34 ) 35 36 test_src = files( 37 'clock.c', 38 'taskbar.c', 39 'test/clock.c', 40 'test/main.c', 41 'test/taskbar.c', 42 ) -
uspace/app/taskbar/taskbar.c
r3fd38b2 rc77cfd8 92 92 rc = ui_get_rect(taskbar->ui, &scr_rect); 93 93 if (rc != EOK) { 94 printf("Error getting screen dimensions.\n"); 95 goto error; 94 if (str_cmp(display_spec, UI_DISPLAY_NULL) != 0) { 95 printf("Error getting screen dimensions.\n"); 96 goto error; 97 } 98 99 /* For the sake of unit tests */ 100 scr_rect.p0.x = 0; 101 scr_rect.p0.y = 0; 102 scr_rect.p1.x = 100; 103 scr_rect.p1.y = 100; 96 104 } 97 105 … … 194 202 void taskbar_destroy(taskbar_t *taskbar) 195 203 { 204 ui_fixed_remove(taskbar->fixed, taskbar_clock_ctl(taskbar->clock)); 196 205 taskbar_clock_destroy(taskbar->clock); 197 206 ui_window_destroy(taskbar->window); -
uspace/app/taskbar/types/clock.h
r3fd38b2 rc77cfd8 55 55 gfx_rect_t rect; 56 56 57 /** Clock lock */ 58 fibril_mutex_t lock; 59 57 60 /** Clock update timer */ 58 61 fibril_timer_t *timer; 62 63 /** Signal to timer that we are cleaning up */ 64 bool timer_cleanup; 65 66 /** Signal to maih thread that timer is done */ 67 bool timer_done; 68 69 /** Timer done condition variable */ 70 fibril_condvar_t timer_done_cv; 59 71 } taskbar_clock_t; 60 72
Note:
See TracChangeset
for help on using the changeset viewer.