Commit 684fe92
committed
progress: use wall clock time to update progress instead of SIGALRM
An interval timer is set up using setitimer() that delivers a SIGALRM
whose handler sets a flag that is then inspected to know when to write
a new progress message. This also resets the flag.
The decision whether to write a new progress message or not is
effectively a synchronous operation. For example, if a call to
display_progress() were delayed for many seconds, the SIGALRM that
arrives every second cannot do anything about it---no update would
occur until the call of display_progress() finally happens.
Being synchronous enables a different scheme to decide when it is time
to write an updated progress message: by looking at the clock.
Replace the signal-based scheme by keeping track of when the last
update happened. Retrieve the current time on every call to
display_progress() and only update when a fixed interval has elapsed.
Change the interval to 0.1 seconds to achieve smoother updates.
Signed-off-by: Johannes Sixt <j6t@kdbg.org>1 parent 2462961 commit 684fe92
3 files changed
+26
-51
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
| 48 | + | |
48 | 49 | | |
49 | 50 | | |
50 | 51 | | |
51 | 52 | | |
52 | 53 | | |
53 | | - | |
54 | | - | |
55 | 54 | | |
56 | 55 | | |
57 | 56 | | |
58 | 57 | | |
59 | 58 | | |
60 | 59 | | |
61 | | - | |
62 | | - | |
63 | | - | |
64 | | - | |
65 | | - | |
66 | | - | |
67 | | - | |
| 60 | + | |
68 | 61 | | |
69 | | - | |
| 62 | + | |
70 | 63 | | |
71 | 64 | | |
72 | | - | |
73 | | - | |
74 | | - | |
75 | | - | |
76 | | - | |
77 | | - | |
78 | | - | |
79 | | - | |
80 | | - | |
81 | | - | |
82 | | - | |
83 | | - | |
84 | | - | |
85 | | - | |
86 | | - | |
87 | | - | |
88 | | - | |
89 | | - | |
90 | | - | |
91 | | - | |
92 | | - | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
93 | 71 | | |
94 | | - | |
| 72 | + | |
95 | 73 | | |
96 | | - | |
97 | | - | |
98 | | - | |
99 | | - | |
100 | | - | |
101 | | - | |
102 | | - | |
103 | | - | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
104 | 80 | | |
105 | 81 | | |
106 | 82 | | |
| |||
109 | 85 | | |
110 | 86 | | |
111 | 87 | | |
112 | | - | |
| 88 | + | |
| 89 | + | |
113 | 90 | | |
114 | 91 | | |
115 | 92 | | |
| |||
246 | 223 | | |
247 | 224 | | |
248 | 225 | | |
249 | | - | |
250 | | - | |
| 226 | + | |
| 227 | + | |
251 | 228 | | |
252 | 229 | | |
253 | 230 | | |
254 | 231 | | |
255 | 232 | | |
256 | | - | |
| 233 | + | |
257 | 234 | | |
258 | 235 | | |
259 | 236 | | |
| |||
266 | 243 | | |
267 | 244 | | |
268 | 245 | | |
269 | | - | |
| 246 | + | |
270 | 247 | | |
271 | 248 | | |
272 | 249 | | |
| 250 | + | |
273 | 251 | | |
274 | 252 | | |
275 | 253 | | |
276 | | - | |
277 | 254 | | |
278 | 255 | | |
279 | 256 | | |
| |||
341 | 318 | | |
342 | 319 | | |
343 | 320 | | |
344 | | - | |
345 | 321 | | |
346 | | - | |
| 322 | + | |
347 | 323 | | |
348 | 324 | | |
349 | 325 | | |
| |||
376 | 352 | | |
377 | 353 | | |
378 | 354 | | |
379 | | - | |
380 | 355 | | |
381 | 356 | | |
382 | 357 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
| 12 | + | |
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
87 | 87 | | |
88 | 88 | | |
89 | 89 | | |
90 | | - | |
| 90 | + | |
91 | 91 | | |
92 | 92 | | |
93 | 93 | | |
| |||
0 commit comments