1#include "../cache.h" 2#include "progress.h" 3 4static void null_progress__update(struct ui_progress *p __maybe_unused) 5{ 6} 7 8static struct ui_progress_ops null_progress__ops = 9{ 10 .update = null_progress__update, 11}; 12 13struct ui_progress_ops *ui_progress__ops = &null_progress__ops; 14 15void ui_progress__update(struct ui_progress *p, u64 adv) 16{ 17 p->curr += adv; 18 19 if (p->curr >= p->next) { 20 p->next += p->step; 21 ui_progress__ops->update(p); 22 } 23} 24 25void ui_progress__init(struct ui_progress *p, u64 total, const char *title) 26{ 27 p->curr = 0; 28 p->next = p->step = total / 16; 29 p->total = total; 30 p->title = title; 31 32} 33 34void ui_progress__finish(void) 35{ 36 if (ui_progress__ops->finish) 37 ui_progress__ops->finish(); 38} 39