Skip to content

Commit fb9a9a7

Browse files
committed
Fixed Tsan errors
1 parent 8756d84 commit fb9a9a7

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

Source/CommandLine.cpp

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,24 @@ static void hideDockIcon()
3838
#endif
3939
}
4040

41+
inline std::mutex& getCoutMutex()
42+
{
43+
static std::mutex m;
44+
return m;
45+
}
46+
47+
inline void logLine (const juce::String& m)
48+
{
49+
const std::scoped_lock sl (getCoutMutex());
50+
std::cout << m << std::endl;
51+
}
52+
53+
inline void logAndFlush (const juce::String& m)
54+
{
55+
const std::scoped_lock sl (getCoutMutex());
56+
std::cout << m << std::flush;
57+
}
58+
4159
//==============================================================================
4260
#if JUCE_MAC
4361
static void kill9WithSomeMercy (int signal)
@@ -78,7 +96,7 @@ void CommandLineValidator::validate (const juce::String& fileOrID, PluginTests::
7896
validator = std::make_unique<ValidationPass> (fileOrID, options, ValidationType::inProcess,
7997
[] (auto id)
8098
{
81-
std::cout << "Started validating: " << id << std::endl;
99+
logLine ("Started validating: " + id);
82100
},
83101
[] (auto, uint32_t exitCode)
84102
{
@@ -89,7 +107,7 @@ void CommandLineValidator::validate (const juce::String& fileOrID, PluginTests::
89107
},
90108
[] (auto m)
91109
{
92-
std::cout << m << std::flush;
110+
logAndFlush (m);
93111
});
94112
}
95113

0 commit comments

Comments
 (0)