1// Licensed to the .NET Foundation under one or more agreements.
2// The .NET Foundation licenses this file to you under the MIT license.
3// See the LICENSE file in the project root for more information.
4
5
6/*============================================================
7**
8** Header: COMThreadPool.h
9**
10** Purpose: Native methods on System.ThreadPool
11** and its inner classes
12**
13**
14===========================================================*/
15
16#ifndef _COMTHREADPOOL_H
17#define _COMTHREADPOOL_H
18
19#include "delegateinfo.h"
20#include "nativeoverlapped.h"
21
22class ThreadPoolNative
23{
24
25public:
26 static FCDECL2(FC_BOOL_RET, CorSetMaxThreads, DWORD workerThreads, DWORD completionPortThreads);
27 static FCDECL2(VOID, CorGetMaxThreads, DWORD* workerThreads, DWORD* completionPortThreads);
28 static FCDECL2(FC_BOOL_RET, CorSetMinThreads, DWORD workerThreads, DWORD completionPortThreads);
29 static FCDECL2(VOID, CorGetMinThreads, DWORD* workerThreads, DWORD* completionPortThreads);
30 static FCDECL2(VOID, CorGetAvailableThreads, DWORD* workerThreads, DWORD* completionPortThreads);
31
32 static FCDECL0(VOID, NotifyRequestProgress);
33 static FCDECL0(FC_BOOL_RET, NotifyRequestComplete);
34
35 static void QCALLTYPE InitializeVMTp(CLR_BOOL* pEnableWorkerTracking);
36
37 static FCDECL1(void, ReportThreadStatus, CLR_BOOL isWorking);
38
39
40 static FCDECL5(LPVOID, CorRegisterWaitForSingleObject,
41 Object* waitObjectUNSAFE,
42 Object* stateUNSAFE,
43 UINT32 timeout,
44 CLR_BOOL executeOnlyOnce,
45 Object* registeredWaitObjectUNSAFE);
46
47 static BOOL QCALLTYPE RequestWorkerThread();
48
49 static FCDECL1(FC_BOOL_RET, CorPostQueuedCompletionStatus, LPOVERLAPPED lpOverlapped);
50 static FCDECL2(FC_BOOL_RET, CorUnregisterWait, LPVOID WaitHandle, Object * objectToNotify);
51 static FCDECL1(void, CorWaitHandleCleanupNative, LPVOID WaitHandle);
52 static FCDECL1(FC_BOOL_RET, CorBindIoCompletionCallback, HANDLE fileHandle);
53};
54
55class AppDomainTimerNative
56{
57public:
58 static HANDLE QCALLTYPE CreateAppDomainTimer(INT32 dueTime, INT32 timerId);
59 static BOOL QCALLTYPE ChangeAppDomainTimer(HANDLE hTimer, INT32 dueTime);
60 static BOOL QCALLTYPE DeleteAppDomainTimer(HANDLE hTimer);
61};
62
63VOID QueueUserWorkItemManagedCallback(PVOID pArg);
64void WINAPI BindIoCompletionCallbackStub(DWORD ErrorCode,
65 DWORD numBytesTransferred,
66 LPOVERLAPPED lpOverlapped);
67void SetAsyncResultProperties(
68 OVERLAPPEDDATAREF overlapped,
69 DWORD dwErrorCode,
70 DWORD dwNumBytes);
71
72#endif
73