1 //----------------------------------------------------------------------------- 2 // 3 // WaitImpl.h 4 // 5 // WinRT implementation of a base class for objects we 6 // want to be able to wait for. 7 // 8 // Copyright (c) 2015 Microsoft Corporation 9 // All rights reserved. 10 // 11 // SOFTWARE NOTICE AND LICENSE 12 // 13 // This file is part of OpenZWave. 14 // 15 // OpenZWave is free software: you can redistribute it and/or modify 16 // it under the terms of the GNU Lesser General Public License as published 17 // by the Free Software Foundation, either version 3 of the License, 18 // or (at your option) any later version. 19 // 20 // OpenZWave is distributed in the hope that it will be useful, 21 // but WITHOUT ANY WARRANTY; without even the implied warranty of 22 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 23 // GNU Lesser General Public License for more details. 24 // 25 // You should have received a copy of the GNU Lesser General Public License 26 // along with OpenZWave. If not, see <http://www.gnu.org/licenses/>. 27 // 28 //----------------------------------------------------------------------------- 29 #ifndef _WaitImpl_H 30 #define _WaitImpl_H 31 32 #include <windows.h> 33 #include <list> 34 #include "Defs.h" 35 #include "platform/Ref.h" 36 #include "platform/Wait.h" 37 38 namespace OpenZWave 39 { 40 namespace Internal 41 { 42 namespace Platform 43 { 44 45 /** \brief Windows specific implementation of Wait objects. 46 */ 47 class WaitImpl 48 { 49 private: 50 friend class Wait; 51 52 WaitImpl(Wait* _owner); 53 virtual ~WaitImpl(); 54 55 void AddWatcher(Wait::pfnWaitNotification_t _callback, void* _context); 56 bool RemoveWatcher(Wait::pfnWaitNotification_t _callback, void* _context); 57 void Notify(); 58 59 static int32 Multiple(Wait** _objects, uint32 _numObjects, int32 _timeout = -1); 60 61 WaitImpl(Wait const&); // prevent copy 62 WaitImpl& operator =(WaitImpl const&); // prevent assignment 63 64 struct Watcher 65 { 66 Wait::pfnWaitNotification_t m_callback; 67 void* m_context; 68 }; 69 70 list<Watcher> m_watchers; 71 Wait* m_owner; 72 CRITICAL_SECTION m_criticalSection; 73 }; 74 } // namespace Platform 75 } // namespace Internal 76 } // namespace OpenZWave 77 78 #endif //_WaitImpl_H 79 80