mirror of https://github.com/tongzx/nt5src
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
69 lines
1.6 KiB
69 lines
1.6 KiB
//+---------------------------------------------------------------------------
|
|
//
|
|
// Microsoft Windows
|
|
// Copyright (C) Microsoft Corporation, 1997.
|
|
//
|
|
// File: E V E N T Q . H
|
|
//
|
|
// Contents: Event Queue for managing synchonization of external events.
|
|
//
|
|
// Notes:
|
|
//
|
|
// Author: ckotze 29 Nov 2000
|
|
//
|
|
//----------------------------------------------------------------------------
|
|
|
|
#pragma once
|
|
#include "nmbase.h"
|
|
#include <ncstl.h>
|
|
#include <stlqueue.h>
|
|
|
|
using namespace std;
|
|
|
|
class CEvent
|
|
{
|
|
public:
|
|
CEvent(HANDLE hEvent);
|
|
~CEvent();
|
|
|
|
HRESULT SetEvent();
|
|
HRESULT ResetEvent();
|
|
|
|
private:
|
|
HANDLE m_hEvent;
|
|
BOOL m_bSignaled;
|
|
};
|
|
|
|
enum EVENT_MANAGER;
|
|
|
|
typedef struct tagUSERWORKITEM
|
|
{
|
|
LPTHREAD_START_ROUTINE Function;
|
|
PVOID Event;
|
|
EVENT_MANAGER EventMgr;
|
|
} USERWORKITEM;
|
|
|
|
typedef list<USERWORKITEM> EVENTQUEUE;
|
|
typedef EVENTQUEUE::iterator EVENTQUEUEITER;
|
|
|
|
class CEventQueue
|
|
{
|
|
public:
|
|
CEventQueue(HANDLE hServiceShutdown);
|
|
~CEventQueue();
|
|
|
|
HRESULT EnqueueEvent(IN LPTHREAD_START_ROUTINE Function, IN PVOID pEvent, IN const EVENT_MANAGER EventMgr);
|
|
HRESULT DequeueEvent(OUT LPTHREAD_START_ROUTINE& Function, OUT PVOID& pEvent, OUT EVENT_MANAGER& EventMgr);
|
|
BOOL AtomCheckSizeAndResetEvent(const BOOL fDispatchEvents);
|
|
DWORD WaitForExit();
|
|
size_t size();
|
|
|
|
private:
|
|
EVENTQUEUE m_eqWorkItems;
|
|
CRITICAL_SECTION m_csQueue;
|
|
CEvent* m_pFireEvents;
|
|
HANDLE m_hServiceShutdown;
|
|
HANDLE m_hWait;
|
|
BOOL m_fRefreshAllInQueue;
|
|
};
|
|
|