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:
@@ -545,6 +545,12 @@ void stdinIsTerminal(WrenVM* vm)
|
||||
wrenSetSlotBool(vm, 0, uv_guess_handle(stdinDescriptor) == UV_TTY);
|
||||
}
|
||||
|
||||
void stdoutFlush(WrenVM* vm)
|
||||
{
|
||||
fflush(stdout);
|
||||
wrenSetSlotNull(vm, 0);
|
||||
}
|
||||
|
||||
static void allocCallback(uv_handle_t* handle, size_t suggestedSize,
|
||||
uv_buf_t* buf)
|
||||
{
|
||||
|
||||
@@ -297,3 +297,7 @@ class Stdin {
|
||||
foreign static readStart_()
|
||||
foreign static readStop_()
|
||||
}
|
||||
|
||||
class Stdout {
|
||||
foreign static flush()
|
||||
}
|
||||
|
||||
@@ -298,4 +298,8 @@ static const char* ioModuleSource =
|
||||
"\n"
|
||||
" foreign static readStart_()\n"
|
||||
" foreign static readStop_()\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"class Stdout {\n"
|
||||
" foreign static flush()\n"
|
||||
"}\n";
|
||||
|
||||
Reference in New Issue
Block a user