-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathScheduler.h
69 lines (47 loc) · 1.25 KB
/
Scheduler.h
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
65
66
67
68
69
// Scheduler.h: interface for the CScheduler class.
//
//////////////////////////////////////////////////////////////////////
#ifndef SCHEDULER_H
#define SCHEDULER_H
#pragma once
#include "common.h"
class CScheduler
{
private:
////////////////////////// Class Members ////////////////////////////
HANDLE* m_hThreads;
DWORD m_dwThreadNum;
//////////////////////// Thread entry point /////////////////////////
static DWORD WINAPI SvcRun(PVOID pvArgs)
{
CScheduler* this_obj = static_cast<CScheduler*>(pvArgs);
this_obj->Dispatch();
}
public:
CScheduler(DWORD dwThreadNum = 0)
{
if (dwThreadNum == 0)
{
CSystemInfo si;
m_dwThreadNum = si.dwNumberOfProcessors;
}
else m_dwThreadNum = dwThreadNum;
m_hThreads = new HANDLE[m_dwThreadNum];
for (DWORD i = 0; i < m_dwThreadNum; ++i)
{
DWORD dwThreadId;
m_hThreads[i] = CreateThread(NULL, 0, CScheduler::SvcRun, this, 0, &dwThreadId);
ASSERT(m_hThreads[i] != NULL);
TRACE(TEXT("Creato Scheduler Thread: Handle 0x%x, Id %i"), m_hThreads[i], dwThreadId);
CloseHandle(m_hThreads[i]);
}
}
void Dispatch()
{
}
void Insert(MethodRequest)
{
}
virtual ~CScheduler();
};
#endif //SCHEDULER_H