1 // Licensed under the Apache License, Version 2.0 2 // <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license 3 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. 4 // All files in the project carrying such notice may not be copied, modified, or distributed 5 // except according to those terms. 6 //! ApiSet Contract for api-ms-win-core-threadpool-l1. 7 use shared::basetsd::ULONG_PTR; 8 use shared::minwindef::{BOOL, DWORD, HMODULE, PFILETIME, ULONG}; 9 use um::minwinbase::PCRITICAL_SECTION; 10 use um::winnt::{ 11 HANDLE, PTP_CALLBACK_ENVIRON, PTP_CALLBACK_INSTANCE, PTP_CLEANUP_GROUP, PTP_IO, PTP_POOL, 12 PTP_POOL_STACK_INFORMATION, PTP_SIMPLE_CALLBACK, PTP_TIMER, PTP_TIMER_CALLBACK, PTP_WAIT, 13 PTP_WAIT_CALLBACK, PTP_WORK, PTP_WORK_CALLBACK, PVOID, 14 }; 15 FN!{stdcall PTP_WIN32_IO_CALLBACK( 16 Instance: PTP_CALLBACK_INSTANCE, 17 Context: PVOID, 18 Overlapped: PVOID, 19 IoResult: ULONG, 20 NumberOfBytesTransferred: ULONG_PTR, 21 Io: PTP_IO, 22 ) -> ()} 23 extern "system" { CreateThreadpool( reserved: PVOID, ) -> PTP_POOL24 pub fn CreateThreadpool( 25 reserved: PVOID, 26 ) -> PTP_POOL; SetThreadpoolThreadMaximum( ptpp: PTP_POOL, cthrdMost: DWORD, ) -> ()27 pub fn SetThreadpoolThreadMaximum( 28 ptpp: PTP_POOL, 29 cthrdMost: DWORD, 30 ) -> (); SetThreadpoolThreadMinimum( ptpp: PTP_POOL, cthrdMic: DWORD, ) -> BOOL31 pub fn SetThreadpoolThreadMinimum( 32 ptpp: PTP_POOL, 33 cthrdMic: DWORD, 34 ) -> BOOL; SetThreadpoolStackInformation( ptpp: PTP_POOL, ptpsi: PTP_POOL_STACK_INFORMATION, ) -> BOOL35 pub fn SetThreadpoolStackInformation( 36 ptpp: PTP_POOL, 37 ptpsi: PTP_POOL_STACK_INFORMATION, 38 ) -> BOOL; QueryThreadpoolStackInformation( ptpp: PTP_POOL, ptpsi: PTP_POOL_STACK_INFORMATION, ) -> BOOL39 pub fn QueryThreadpoolStackInformation( 40 ptpp: PTP_POOL, 41 ptpsi: PTP_POOL_STACK_INFORMATION, 42 ) -> BOOL; CloseThreadpool( ptpp: PTP_POOL, ) -> ()43 pub fn CloseThreadpool( 44 ptpp: PTP_POOL, 45 ) -> (); CreateThreadpoolCleanupGroup() -> PTP_CLEANUP_GROUP46 pub fn CreateThreadpoolCleanupGroup() -> PTP_CLEANUP_GROUP; CloseThreadpoolCleanupGroupMembers( ptpcg: PTP_CLEANUP_GROUP, fCancelPendingCallbacks: BOOL, pvCleanupContext: PVOID, ) -> ()47 pub fn CloseThreadpoolCleanupGroupMembers( 48 ptpcg: PTP_CLEANUP_GROUP, 49 fCancelPendingCallbacks: BOOL, 50 pvCleanupContext: PVOID, 51 ) -> (); CloseThreadpoolCleanupGroup( ptpcg: PTP_CLEANUP_GROUP, ) -> ()52 pub fn CloseThreadpoolCleanupGroup( 53 ptpcg: PTP_CLEANUP_GROUP, 54 ) -> (); SetEventWhenCallbackReturns( pci: PTP_CALLBACK_INSTANCE, evt: HANDLE, ) -> ()55 pub fn SetEventWhenCallbackReturns( 56 pci: PTP_CALLBACK_INSTANCE, 57 evt: HANDLE, 58 ) -> (); ReleaseSemaphoreWhenCallbackReturns( pci: PTP_CALLBACK_INSTANCE, sem: HANDLE, crel: DWORD, ) -> ()59 pub fn ReleaseSemaphoreWhenCallbackReturns( 60 pci: PTP_CALLBACK_INSTANCE, 61 sem: HANDLE, 62 crel: DWORD, 63 ) -> (); ReleaseMutexWhenCallbackReturns( pci: PTP_CALLBACK_INSTANCE, mut_: HANDLE, ) -> ()64 pub fn ReleaseMutexWhenCallbackReturns( 65 pci: PTP_CALLBACK_INSTANCE, 66 mut_: HANDLE, 67 ) -> (); LeaveCriticalSectionWhenCallbackReturns( pci: PTP_CALLBACK_INSTANCE, pcs: PCRITICAL_SECTION, ) -> ()68 pub fn LeaveCriticalSectionWhenCallbackReturns( 69 pci: PTP_CALLBACK_INSTANCE, 70 pcs: PCRITICAL_SECTION, 71 ) -> (); FreeLibraryWhenCallbackReturns( pci: PTP_CALLBACK_INSTANCE, mod_: HMODULE, ) -> ()72 pub fn FreeLibraryWhenCallbackReturns( 73 pci: PTP_CALLBACK_INSTANCE, 74 mod_: HMODULE, 75 ) -> (); CallbackMayRunLong( pci: PTP_CALLBACK_INSTANCE, ) -> BOOL76 pub fn CallbackMayRunLong( 77 pci: PTP_CALLBACK_INSTANCE, 78 ) -> BOOL; DisassociateCurrentThreadFromCallback( pci: PTP_CALLBACK_INSTANCE, ) -> ()79 pub fn DisassociateCurrentThreadFromCallback( 80 pci: PTP_CALLBACK_INSTANCE, 81 ) -> (); TrySubmitThreadpoolCallback( pfns: PTP_SIMPLE_CALLBACK, pv: PVOID, pcbe: PTP_CALLBACK_ENVIRON, ) -> BOOL82 pub fn TrySubmitThreadpoolCallback( 83 pfns: PTP_SIMPLE_CALLBACK, 84 pv: PVOID, 85 pcbe: PTP_CALLBACK_ENVIRON, 86 ) -> BOOL; CreateThreadpoolWork( pfnwk: PTP_WORK_CALLBACK, pv: PVOID, pcbe: PTP_CALLBACK_ENVIRON, ) -> PTP_WORK87 pub fn CreateThreadpoolWork( 88 pfnwk: PTP_WORK_CALLBACK, 89 pv: PVOID, 90 pcbe: PTP_CALLBACK_ENVIRON, 91 ) -> PTP_WORK; SubmitThreadpoolWork( pwk: PTP_WORK, ) -> ()92 pub fn SubmitThreadpoolWork( 93 pwk: PTP_WORK, 94 ) -> (); WaitForThreadpoolWorkCallbacks( pwk: PTP_WORK, fCancelPendingCallbacks: BOOL, ) -> ()95 pub fn WaitForThreadpoolWorkCallbacks( 96 pwk: PTP_WORK, 97 fCancelPendingCallbacks: BOOL, 98 ) -> (); CloseThreadpoolWork( pwk: PTP_WORK, ) -> ()99 pub fn CloseThreadpoolWork( 100 pwk: PTP_WORK, 101 ) -> (); CreateThreadpoolTimer( pfnti: PTP_TIMER_CALLBACK, pv: PVOID, pcbe: PTP_CALLBACK_ENVIRON, ) -> PTP_TIMER102 pub fn CreateThreadpoolTimer( 103 pfnti: PTP_TIMER_CALLBACK, 104 pv: PVOID, 105 pcbe: PTP_CALLBACK_ENVIRON, 106 ) -> PTP_TIMER; SetThreadpoolTimer( pti: PTP_TIMER, pftDueTime: PFILETIME, msPeriod: DWORD, msWindowLength: DWORD, ) -> ()107 pub fn SetThreadpoolTimer( 108 pti: PTP_TIMER, 109 pftDueTime: PFILETIME, 110 msPeriod: DWORD, 111 msWindowLength: DWORD, 112 ) -> (); IsThreadpoolTimerSet( pti: PTP_TIMER, ) -> BOOL113 pub fn IsThreadpoolTimerSet( 114 pti: PTP_TIMER, 115 ) -> BOOL; WaitForThreadpoolTimerCallbacks( pti: PTP_TIMER, fCancelPendingCallbacks: BOOL, ) -> ()116 pub fn WaitForThreadpoolTimerCallbacks( 117 pti: PTP_TIMER, 118 fCancelPendingCallbacks: BOOL, 119 ) -> (); CloseThreadpoolTimer( pti: PTP_TIMER, ) -> ()120 pub fn CloseThreadpoolTimer( 121 pti: PTP_TIMER, 122 ) -> (); CreateThreadpoolWait( pfnwa: PTP_WAIT_CALLBACK, pv: PVOID, pcbe: PTP_CALLBACK_ENVIRON, ) -> PTP_WAIT123 pub fn CreateThreadpoolWait( 124 pfnwa: PTP_WAIT_CALLBACK, 125 pv: PVOID, 126 pcbe: PTP_CALLBACK_ENVIRON, 127 ) -> PTP_WAIT; SetThreadpoolWait( pwa: PTP_WAIT, h: HANDLE, pftTimeout: PFILETIME, ) -> ()128 pub fn SetThreadpoolWait( 129 pwa: PTP_WAIT, 130 h: HANDLE, 131 pftTimeout: PFILETIME, 132 ) -> (); WaitForThreadpoolWaitCallbacks( pwa: PTP_WAIT, fCancelPendingCallbacks: BOOL, ) -> ()133 pub fn WaitForThreadpoolWaitCallbacks( 134 pwa: PTP_WAIT, 135 fCancelPendingCallbacks: BOOL, 136 ) -> (); CloseThreadpoolWait( pwa: PTP_WAIT, ) -> ()137 pub fn CloseThreadpoolWait( 138 pwa: PTP_WAIT, 139 ) -> (); CreateThreadpoolIo( fl: HANDLE, pfnio: PTP_WIN32_IO_CALLBACK, pv: PVOID, pcbe: PTP_CALLBACK_ENVIRON, ) -> PTP_IO140 pub fn CreateThreadpoolIo( 141 fl: HANDLE, 142 pfnio: PTP_WIN32_IO_CALLBACK, 143 pv: PVOID, 144 pcbe: PTP_CALLBACK_ENVIRON, 145 ) -> PTP_IO; StartThreadpoolIo( pio: PTP_IO, ) -> ()146 pub fn StartThreadpoolIo( 147 pio: PTP_IO, 148 ) -> (); CancelThreadpoolIo( pio: PTP_IO, ) -> ()149 pub fn CancelThreadpoolIo( 150 pio: PTP_IO, 151 ) -> (); WaitForThreadpoolIoCallbacks( pio: PTP_IO, fCancelPendingCallbacks: BOOL, ) -> ()152 pub fn WaitForThreadpoolIoCallbacks( 153 pio: PTP_IO, 154 fCancelPendingCallbacks: BOOL, 155 ) -> (); CloseThreadpoolIo( pio: PTP_IO, ) -> ()156 pub fn CloseThreadpoolIo( 157 pio: PTP_IO, 158 ) -> (); SetThreadpoolTimerEx( pti: PTP_TIMER, pftDueTime: PFILETIME, msPeriod: DWORD, msWindowLength: DWORD, ) -> BOOL159 pub fn SetThreadpoolTimerEx( 160 pti: PTP_TIMER, 161 pftDueTime: PFILETIME, 162 msPeriod: DWORD, 163 msWindowLength: DWORD, 164 ) -> BOOL; SetThreadpoolWaitEx( pwa: PTP_WAIT, h: HANDLE, pftTimeout: PFILETIME, Reserved: PVOID, ) -> BOOL165 pub fn SetThreadpoolWaitEx( 166 pwa: PTP_WAIT, 167 h: HANDLE, 168 pftTimeout: PFILETIME, 169 Reserved: PVOID, 170 ) -> BOOL; 171 } 172