dokan_pool.h
1 /*
2  Dokan : user-mode file system library for Windows
3 
4  Copyright (C) 2016 Keith Newton
5  Copyright (C) 2022 - 2023 Google, Inc.
6 
7  http://dokan-dev.github.io
8 
9 This program is free software; you can redistribute it and/or modify it under
10 the terms of the GNU Lesser General Public License as published by the Free
11 Software Foundation; either version 3 of the License, or (at your option) any
12 later version.
13 
14 This program is distributed in the hope that it will be useful, but WITHOUT ANY
15 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16 FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
17 
18 You should have received a copy of the GNU Lesser General Public License along
19 with this program. If not, see <http://www.gnu.org/licenses/>.
20 */
21 
22 #ifndef DOKAN_POOL_H_
23 #define DOKAN_POOL_H_
24 
25 #include "dokani.h"
26 
27 #define DOKAN_PULL_EVENT_TIMEOUT_MS 100
28 #define DOKAN_MAIN_PULL_THREAD_COUNT_MAX 16
29 #define DOKAN_MAIN_PULL_THREAD_COUNT_MIN 2
30 #define BATCH_EVENT_CONTEXT_SIZE (EVENT_CONTEXT_MAX_SIZE * 4)
31 #define DOKAN_IO_BATCH_SIZE \
32  ((SIZE_T)(FIELD_OFFSET(DOKAN_IO_BATCH, EventContext)) + \
33  BATCH_EVENT_CONTEXT_SIZE)
34 
35 #define DOKAN_EVENT_INFO_16K_SIZE \
36  (FIELD_OFFSET(EVENT_INFORMATION, Buffer) + (16 * 1024))
37 #define DOKAN_EVENT_INFO_32K_SIZE \
38  (FIELD_OFFSET(EVENT_INFORMATION, Buffer) + (32 * 1024))
39 #define DOKAN_EVENT_INFO_64K_SIZE \
40  (FIELD_OFFSET(EVENT_INFORMATION, Buffer) + (64 * 1024))
41 #define DOKAN_EVENT_INFO_128K_SIZE \
42  (FIELD_OFFSET(EVENT_INFORMATION, Buffer) + (128 * 1024))
43 
44 PTP_POOL GetThreadPool();
45 int InitializePool();
46 VOID CleanupPool();
47 
48 PDOKAN_IO_BATCH PopIoBatchBuffer();
49 VOID PushIoBatchBuffer(PDOKAN_IO_BATCH IoBatch);
50 VOID FreeIoBatchBuffer(PDOKAN_IO_BATCH IoBatch);
51 
52 PDOKAN_IO_EVENT PopIoEventBuffer();
53 VOID PushIoEventBuffer(PDOKAN_IO_EVENT IoEvent);
54 
55 // Default Event size.
56 PEVENT_INFORMATION PopEventResult();
57 VOID PushEventResult(PEVENT_INFORMATION EventResult);
58 VOID FreeEventResult(PEVENT_INFORMATION EventResult);
59 
60 // Event with extra memory allocated for events holding additional data.
61 PEVENT_INFORMATION Pop16KEventResult();
62 VOID Push16KEventResult(PEVENT_INFORMATION EventResult);
63 PEVENT_INFORMATION Pop32KEventResult();
64 VOID Push32KEventResult(PEVENT_INFORMATION EventResult);
65 PEVENT_INFORMATION Pop64KEventResult();
66 VOID Push64KEventResult(PEVENT_INFORMATION EventResult);
67 PEVENT_INFORMATION Pop128KEventResult();
68 VOID Push128KEventResult(PEVENT_INFORMATION EventResult);
69 
70 PDOKAN_OPEN_INFO PopFileOpenInfo();
71 VOID PushFileOpenInfo(PDOKAN_OPEN_INFO FileInfo);
72 VOID FreeFileOpenInfo(PDOKAN_OPEN_INFO FileInfo);
73 
74 PDOKAN_VECTOR PopDirectoryList();
75 VOID PushDirectoryList(PDOKAN_VECTOR DirectoryList);
76 
77 #endif