浏览代码

[ui] Add progress dots while waiting on any foreground job

Print one dot per second while waiting in monojob.c (e.g. for DHCP,
for file downloads, etc.), to inform user that the system has not
locked up.

Patch contributed by Andrew Schran <aschran@google.com>, minor
modification by me.
tags/v0.9.4
Michael Brown 16 年前
父节点
当前提交
702e0be44e
共有 1 个文件被更改,包括 10 次插入3 次删除
  1. 10
    3
      src/core/monojob.c

+ 10
- 3
src/core/monojob.c 查看文件

@@ -24,6 +24,7 @@
24 24
 #include <gpxe/keys.h>
25 25
 #include <gpxe/job.h>
26 26
 #include <gpxe/monojob.h>
27
+#include <gpxe/timer.h>
27 28
 
28 29
 /** @file
29 30
  *
@@ -62,9 +63,11 @@ struct job_interface monojob = {
62 63
 int monojob_wait ( const char *string ) {
63 64
 	int key;
64 65
 	int rc;
66
+	tick_t last_progress_dot;
65 67
 
66
-	printf ( "%s... ", string );
68
+	printf ( "%s.", string );
67 69
 	monojob_rc = -EINPROGRESS;
70
+	last_progress_dot = currticks();
68 71
 	while ( monojob_rc == -EINPROGRESS ) {
69 72
 		step();
70 73
 		if ( iskey() ) {
@@ -78,14 +81,18 @@ int monojob_wait ( const char *string ) {
78 81
 				break;
79 82
 			}
80 83
 		}
84
+		if ( ( currticks() - last_progress_dot ) > TICKS_PER_SEC ) {
85
+			printf ( "." );
86
+			last_progress_dot = currticks();
87
+		}
81 88
 	}
82 89
 	rc = monojob_rc;
83 90
 
84 91
 done:
85 92
 	if ( rc ) {
86
-		printf ( "%s\n", strerror ( rc ) );
93
+		printf ( " %s\n", strerror ( rc ) );
87 94
 	} else {
88
-		printf ( "ok\n" );
95
+		printf ( " ok\n" );
89 96
 	}
90 97
 	return rc;
91 98
 }

正在加载...
取消
保存