00001 /// \file CATSignal.h 00002 /// \brief Defines an interface for signals (win32 events) for thread syncs 00003 /// \ingroup CAT 00004 /// 00005 /// 00006 /// Copyright (c) 2003-2008 by Michael Ellison. 00007 /// See COPYING.txt for the \ref gaslicense License (MIT License). 00008 /// 00009 // $Author: mikeellison $ 00010 // $Date: 2008-01-21 08:33:12 -0600 (Mon, 21 Jan 2008) $ 00011 // $Revision: $ 00012 // $NoKeywords: $ 00013 //--------------------------------------------------------------------------- 00014 #ifndef _CATSignal_H_ 00015 #define _CATSignal_H_ 00016 00017 #include "CATInternal.h" 00018 00019 /// \class CATSignal 00020 /// \brief Defines an interface for signals (win32 events) for thread syncs 00021 /// \ingroup CAT 00022 /// 00023 /// CATSignal provides a signal or event interface for synchronization 00024 /// between threads. The signal acts like a gate - when fired, it lets 00025 /// someone through. If set to auto-reset, then it only lets the next 00026 /// caller requesting it through. Otherwise, it will allow callers through 00027 /// until it is reset. 00028 class CATSignal 00029 { 00030 public: 00031 CATSignal(bool autoReset = true); 00032 virtual ~CATSignal(); 00033 00034 /// Wait() waits up to [milliseconds] milliseconds for the 00035 /// signal to be fired. If the CATSignal is set to auto-reset, 00036 /// the it will be reset when a caller successfully receive 00037 /// the event through a wait. 00038 /// 00039 /// Check the result code here! It can very easily time out. 00040 /// 00041 /// The default, however, is an infinite wait. 00042 /// 00043 /// \param milliseconds - milliseconds to wait while trying to get synch 00044 /// 00045 /// \sa Release() 00046 CATResult Wait(CATUInt32 milliseconds = 0xFFFFFFFF); 00047 00048 /// Fire() fires the signal, which then allows caller(s) through. 00049 CATResult Fire(); 00050 00051 /// Reset() resets the signal, making the signal block callers. 00052 CATResult Reset(); 00053 00054 #ifdef CAT_CONFIG_WIN32 00055 HANDLE GetWin32Handle(); 00056 #endif 00057 00058 private: 00059 CATSignal& operator=(const CATSignal& srcSignal) 00060 { 00061 CATASSERT(false,"Copying signals is not currently supported."); 00062 return *this; 00063 } 00064 00065 // Platform specific mutex handles 00066 #ifdef CAT_CONFIG_WIN32 00067 HANDLE fEvent; 00068 #endif 00069 }; 00070 00071 00072 #endif // _CATSignal_H_ 00073 00074