@@ -1236,16 +1236,46 @@ class GTEST_API_ [[nodiscard]] AutoHandle {
12361236// Nothing to do here.
12371237
12381238#else
1239- GTEST_DISABLE_MSC_WARNINGS_PUSH_ (4251 \
1240- /* class A needs to have dll-interface to be used by clients of class B */ )
1241-
12421239// Allows a controller thread to pause execution of newly created
12431240// threads until notified. Instances of this class must be created
12441241// and destroyed in the controller thread.
12451242//
12461243// This class is only for testing Google Test's own constructs. Do not
12471244// use it in user tests, either directly or indirectly.
12481245// TODO(b/203539622): Replace unconditionally with absl::Notification.
1246+ #ifdef GTEST_OS_WINDOWS_MINGW
1247+ // GCC version < 13 with the win32 thread model does not provide std::mutex and
1248+ // std::condition_variable in the <mutex> and <condition_variable> headers. So
1249+ // we implement the Notification class using a Windows manual-reset event. See
1250+ // https://gcc.gnu.org/gcc-13/changes.html#windows.
1251+ class GTEST_API_ [[nodiscard]] Notification {
1252+ public:
1253+ Notification ();
1254+ Notification (const Notification&) = delete ;
1255+ Notification& operator =(const Notification&) = delete ;
1256+ ~Notification ();
1257+
1258+ // Notifies all threads created with this notification to start. Must
1259+ // be called from the controller thread.
1260+ void Notify ();
1261+
1262+ // Blocks until the controller thread notifies. Must be called from a test
1263+ // thread.
1264+ void WaitForNotification ();
1265+
1266+ private:
1267+ // Assume that Win32 HANDLE type is equivalent to void*. Doing so allows us to
1268+ // avoid including <windows.h> in this header file. Including <windows.h> is
1269+ // undesirable because it defines a lot of symbols and macros that tend to
1270+ // conflict with client code. This assumption is verified by
1271+ // WindowsTypesTest.HANDLEIsVoidStar.
1272+ typedef void * Handle;
1273+ Handle event_;
1274+ };
1275+ #else
1276+ GTEST_DISABLE_MSC_WARNINGS_PUSH_ (4251 \
1277+ /* class A needs to have dll-interface to be used by clients of class B */ )
1278+
12491279class GTEST_API_ [[nodiscard]] Notification {
12501280 public:
12511281 Notification () : notified_ (false ) {}
@@ -1273,6 +1303,7 @@ class GTEST_API_ [[nodiscard]] Notification {
12731303 bool notified_;
12741304};
12751305GTEST_DISABLE_MSC_WARNINGS_POP_ () // 4251
1306+ #endif // GTEST_OS_WINDOWS_MINGW
12761307#endif // GTEST_HAS_NOTIFICATION_
12771308
12781309// On MinGW, we can have both GTEST_OS_WINDOWS and GTEST_HAS_PTHREAD
0 commit comments