Don't automatically flush on every System.write().

It's handy because it ensures writes are flushed to the terminal before
any calls to read from stdin, but it's also gratuitously slow.

Instead, added a Stdout class with an explicit flush() method that can
be called by the user.

Fix #445.
This commit is contained in:
Bob Nystrom
2017-10-09 07:16:05 -07:00
parent c4b0f83cb3
commit 2021e086bf
9 changed files with 41 additions and 2 deletions
+8
View File
@@ -29,9 +29,17 @@ been received.
Returns the byte value as a number or `null` if stdin is closed.
Note that output is not automatically flushed when calling this. If you want to
display a prompt before reading input, you'll want to call `Stdout.flush()`
after printing the prompt.
### **readLine**()
Reads one line of input from stdin. Blocks the current fiber until a full line
of input has been received.
Returns the string of input or `null` if stdin is closed.
Note that output is not automatically flushed when calling this. If you want to
display a prompt before reading input, you'll want to call `Stdout.flush()`
after printing the prompt.