12 #error TnbCeMsgQueueWatcher.h is only supported on Windows CE platforms.
97 operator HANDLE(
void)
const
118 return m_handle != NULL;
129 bool Start(
size_t maxMessagesCount = 0,
bool isRead =
true, LPCTSTR lpszThreadName = NULL)
131 MSGQUEUEOPTIONS opt = { 0 };
132 opt.dwSize =
sizeof(MSGQUEUEOPTIONS);
134 opt.dwMaxMessages = maxMessagesCount;
135 if ( maxMessagesCount == 0 )
137 opt.dwFlags = MSGQUEUE_NOPRECOMMIT;
139 opt.cbMaxMessage =
sizeof(TYP);
140 opt.bReadAccess = isRead;
141 return m_Start(NULL, opt, lpszThreadName);
152 bool Start(LPCTSTR lpszQueueName,
const MSGQUEUEOPTIONS& option, LPCTSTR lpszThreadName = NULL)
154 MSGQUEUEOPTIONS opt = option;
155 return m_Start(lpszQueueName, opt,lpszThreadName);
167 if ( m_handle != NULL )
169 r = !! ::CloseMsgQueue(m_handle);
184 bool Send(
const TYP& data, DWORD timeout = INFINITE,
bool isAlert =
false)
186 DWORD fg = isAlert ? MSGQUEUE_MSGALERT : 0;
188 return !! ::WriteMsgQueue(m_handle, &t,
sizeof(data), timeout, fg);
199 _info.dwSize =
sizeof(MSGQUEUEINFO);
200 return !! ::GetMsgQueueInfo(m_handle, &_info);
226 DWORD dw = ::WaitForSingleObject(m_handle, INFINITE);
227 if ( dw == WAIT_OBJECT_0 || dw == WAIT_ABANDONED_0 )
232 while ( ::ReadMsgQueue(m_handle, &buf,
sizeof(TYP), &dwRead, 0, &dwFlags) )
234 if ( m_pListener != NULL )
239 DWORD err = ::GetLastError();
240 if ( err != ERROR_TIMEOUT && err != ERROR_INVALID_HANDLE )
242 if ( ERROR_INSUFFICIENT_BUFFER == _GetLastError(
"ReadMsgQueue") )
253 bool m_Start(LPCTSTR lpszQueueName, MSGQUEUEOPTIONS& _opt, LPCTSTR lpszThreadName)
256 _opt.dwSize =
sizeof(MSGQUEUEOPTIONS);
257 m_handle = ::CreateMsgQueue(lpszQueueName, &_opt);
258 if ( m_handle != NULL )
261 if ( lpszThreadName == NULL )
263 lpszThreadName = _T(
"CMsgQueueWatcher");
265 if ( m_thread.
Start(lpszThreadName) )
275 IListener* m_pListener;
CThreadStatus & ReferThreadStatus(void)
[参照] 監視スレッド状態参照.
void SetListener(IListener *P)
[設定] リスナー設定.
bool GetInfo(MSGQUEUEINFO &_info) const
[取得] キュー情報.
~CMsgQueueWatcherT(void)
デストラクタ
bool Send(const TYP &data, DWORD timeout=INFINITE, bool isAlert=false)
[設定] 送信.
bool IsStarted(void) const
[確認] 監視確認.
HANDLE GetSafeHandle(void) const
[取得] ハンドル取得.
bool Start(LPCTSTR lpszQueueName, const MSGQUEUEOPTIONS &option, LPCTSTR lpszThreadName=NULL)
[設定] 監視開始.
bool Start(size_t maxMessagesCount=0, bool isRead=true, LPCTSTR lpszThreadName=NULL)
[設定] 監視開始.
virtual DWORD Run(void)
[動作] スレッド処理本体
CMsgQueueWatcherT(void)
コンストラクタ
bool Stop(void)
[設定] 監視停止.
bool SetRunner(IRunner *pRunner)
[設定] ランナー、設定
bool Stop(DWORD dwWait=15000)
[設定] スレッド停止 スレッドに対して停止要求します。
bool Start(LPCTSTR lpszName=NULL)
[設定] スレッド開始
メッセージキュー監視のリスナーインターフェース (CE専用).
virtual void OnMsgQueueWatcherEvent(const TYP &data, size_t length, bool isAlert)=0
[通知] 受信通知.
virtual ~IListener(void)
デストラクタ
bool IsRunnable(void) const
[確認] 実行可能か否か