Commit 7226451
committed
Add unbuffered print for fiber
A simple solution to avoid unexpected output by the buffered I/O 'printf' is
using low-level I/O interface 'write'. It works because 'printf' will wait to
write to STDOUT until the buffer is full, or on some other conditions. Using
write, however, can write to STDOUT immediately.
Here is a naive implementation for the idea with some limitation and weakness
that need improvement:
1. It will fail if the formatted string with length >64
2. The function 'write' can write less than n bytes. It will need further
handling if happens.1 parent 41be11a commit 7226451
1 file changed
+20
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
22 | 42 | | |
23 | 43 | | |
24 | 44 | | |
| |||
0 commit comments