📄 thresholdmonitorthread.h
字号:
/*
Copyright (c) 2008, Intel Corporation.
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation and/or
other materials provided with the distribution.
* Neither the name of Intel Corporation nor the names of its contributors
may be used to endorse or promote products derived from this software without
specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
OF SUCH DAMAGE.
*///==============================================================================// ThresholdMonitorThread.h // Declaration of the class ThresholdMonitorThread//==============================================================================// This is a utility class that ThresholdManager uses to manage the thread that // periodically checks the thresholds on a property.// It contains a thread-safe list of all of the thresholds. When the list contains items, a thread runs on// the LPTHREAD_START_ROUTINE parameter provided to the constructor, and the 'this' ThresholdMonitorThread object// is passed as the Parameter to the thread. The LPTHREAD_START_ROUTINE should REGULARLY call the IsThreadActive method// because when there are not Thresholds in the list, the ThresholdMonitorThread object shuts down the thread, and // TERMNIATES it if it does not shut itself down within the period specified by ShutdownWaitLength().//// This class also provides a pointer to the ThresholdManager so that // ThresholdEvents can be fired to the subscribers.//==============================================================================#ifndef _THRESHOLDMONITORTHREAD_H#define _THRESHOLDMONITORTHREAD_H#include "inc/framework/win2linux.h"#include "inc/framework/base_LoggerBase.h"class ThresholdManager;//==============================================================================// ThresholdMonitorThreadclass ThresholdMonitorThread : public LoggerBase{protected: ThresholdManager* m_pThresholdManager; // ThresholdManager ownes the vector of thresholds HANDLE m_hThreadHandle; bool m_bThreadActive; long m_lCheckInterval; long m_lThreadWaitInterval;public: ThresholdMonitorThread( CLog& theLog, ThresholdManager* pManager = NULL, long lInterval = 10000, // Default = 10 sec. long lWait = 3000 ); ~ThresholdMonitorThread(); void SetManager( ThresholdManager* pManager ) { m_pThresholdManager = pManager; } static DWORD MonitorProc( LPVOID pParam ); // The thread start routine bool Monitor(); // The main processing method // Sets the interval in ms at which the loop calls the check routine. long SetCheckInterval( long lInterval ); // Gets the interval in ms at which the loop calls the check routine. long GetCheckInterval(); // Allows the caller to determine how long the ThresholdMonitorThread object // will wait before Terminating the monitor thread. // More specifically, it is the time between IsThreadActive() returns true, // and the time the thread is terminated and not allowed to clean up. // This time is 3000 by default, but may need to be lengthened depending // on how many thresholds are being monitored and how long it takes to obtain // the current value of a property. void SetShutdownWaitLength ( long lMilliSeconds ); long GetShutdownWaitLength (); // The ThresholdManager will call this method to determine if it needs to // start or stop the thread. bool IsThreadActive(); HRESULT StartThread(); HRESULT StopThread ();};//==============================================================================#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -