aboutsummaryrefslogtreecommitdiff
path: root/x86_64-w64-mingw32/include/mspthrd.h
blob: b99b5c8f921fffaa6c66dbec5c7589de6591fc49 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/**
 * This file has no copyright assigned and is placed in the Public Domain.
 * This file is part of the mingw-w64 runtime package.
 * No warranty is given; refer to the file DISCLAIMER.PD within this package.
 */
#ifndef __MSPTHRD_H
#define __MSPTHRD_H

typedef enum {
  WORK_ITEM,STOP
} COMMAND;

typedef struct {
  COMMAND cmd;
  LPTHREAD_START_ROUTINE pfn;
  PVOID pContext;
  HANDLE hEvent;
} COMMAND_NODE;

typedef struct {
  LIST_ENTRY link;
  COMMAND_NODE node;
} COMMAND_QUEUE_ITEM;

typedef struct _NOTIF_LIST {
  CMSPAddress *addr;
  _NOTIF_LIST *next;
} NOTIF_LIST,*PNOTIF_LIST;

class CMSPThread {
public:
  CMSPThread() {
    InitializeListHead(&m_CommandQueue);
    m_hCommandEvent = NULL;
    m_hThread = NULL;
    m_NotifList = NULL;
    m_iStartCount = 0;
  }
  ~CMSPThread() { };
  HRESULT Start();
  HRESULT Stop();
  HRESULT Shutdown();
  HRESULT ThreadProc();
  static LRESULT CALLBACK NotifWndProc(HWND hwnd,UINT uMsg,WPARAM wParam,LPARAM lParam);
  HRESULT RegisterPnpNotification(CMSPAddress *pCMSPAddress);
  HRESULT UnregisterPnpNotification(CMSPAddress *pCMSPAddress);
  HRESULT QueueWorkItem(LPTHREAD_START_ROUTINE Function,PVOID Context,WINBOOL fSynchronous);
private:
  WINBOOL SignalThreadProc() { return SetEvent(m_hCommandEvent); }
  CMSPCritSection m_CountLock;
  CMSPCritSection m_QueueLock;
  int m_iStartCount;
  LIST_ENTRY m_CommandQueue;
  HANDLE m_hCommandEvent;
  HANDLE m_hThread;
  HDEVNOTIFY m_hDevNotifyVideo;
  HDEVNOTIFY m_hDevNotifyAudio;
  HWND m_hWndNotif;
  PNOTIF_LIST m_NotifList;
  CMSPCritSection m_NotifLock;
};

extern CMSPThread g_Thread;
#endif