Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use thread-safe writeln in dart-sdk 3.3 #2206

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 2 additions & 11 deletions lib/src/io/vm.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,11 @@ bool get supportsAnsiEscapes {
}

void safePrint(Object? message) {
_threadSafeWriteLn(io.stdout, message);
io.stdout.writeln(message.toString());
}

void printError(Object? message) {
_threadSafeWriteLn(io.stderr, message);
}

void _threadSafeWriteLn(io.IOSink sink, Object? message) {
// This does have performance penality of copying buffer
// if message is already a StringBuffer.
// https://github.com/dart-lang/sdk/issues/53471.
var buffer = StringBuffer(message.toString());
buffer.writeln();
sink.write(buffer);
io.stderr.writeln(message.toString());
}

String readFile(String path) {
Expand Down
Loading