From 4f6c874c108871a1ab4c063ab4a8de2775f7a01d Mon Sep 17 00:00:00 2001 From: Zahary Karadjov Date: Fri, 27 Nov 2020 19:32:04 +0200 Subject: [PATCH] Add a helper for initializing fsStdOut in threads --- faststreams/stdout.nim | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/faststreams/stdout.nim b/faststreams/stdout.nim index beaccdd..d57aa5f 100644 --- a/faststreams/stdout.nim +++ b/faststreams/stdout.nim @@ -1,5 +1,13 @@ import outputs -let fsStdOut* {.threadvar.} = fileOutput(system.stdout) +var fsStdOut* {.threadvar.}: OutputStream + +proc initFsStdOut* = + ## This proc must be called in each thread where + ## the `fsStdOut` variable will be used. + if fsStdOut == nil: + fsStdOut = fileOutput(system.stdout) + +initFsStdOut()