1 // Copyright 2013 The Flutter Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef FLUTTER_FML_PLATFORM_WIN_MESSAGE_LOOP_WIN_H_ 6 #define FLUTTER_FML_PLATFORM_WIN_MESSAGE_LOOP_WIN_H_ 7 8 #include <atomic> 9 10 #include <windows.h> 11 12 #include "flutter/fml/macros.h" 13 #include "flutter/fml/message_loop_impl.h" 14 #include "flutter/fml/unique_object.h" 15 16 namespace fml { 17 18 class MessageLoopWin : public MessageLoopImpl { 19 private: 20 struct UniqueHandleTraits { InvalidValueUniqueHandleTraits21 static HANDLE InvalidValue() { return NULL; } IsValidUniqueHandleTraits22 static bool IsValid(HANDLE value) { return value != NULL; } FreeUniqueHandleTraits23 static void Free(HANDLE value) { CloseHandle(value); } 24 }; 25 26 bool running_; 27 fml::UniqueObject<HANDLE, UniqueHandleTraits> timer_; 28 29 MessageLoopWin(); 30 31 ~MessageLoopWin() override; 32 33 void Run() override; 34 35 void Terminate() override; 36 37 void WakeUp(fml::TimePoint time_point) override; 38 39 FML_FRIEND_MAKE_REF_COUNTED(MessageLoopWin); 40 FML_FRIEND_REF_COUNTED_THREAD_SAFE(MessageLoopWin); 41 FML_DISALLOW_COPY_AND_ASSIGN(MessageLoopWin); 42 }; 43 44 } // namespace fml 45 46 #endif // FLUTTER_FML_PLATFORM_GENERIC_MESSAGE_LOOP_GENERIC_H_ 47