网站首页  词典首页

请输入您要查询的函数:

 

术语 queueuserworkitem
释义 QueueUserWorkItem
语法:
C++
BOOL WINAPI QueueUserWorkItem(
__in LPTHREAD_START_ROUTINE Function,
__in_opt PVOID Context,
__in ULONG Flags
);
QueueUserWorkItem函数
工作项队列中的一个线程池工作线程。
参数
功能 [in]
该申请的指针定义的类型的回调函数LPTHREAD_START_ROUTINE所要执行的线程池的线程。此值表示线程的起始地址。此回调函数不能调用TerminateThread函数。
有关更多信息,请参阅ThreadProc。
上下文[中,可选]
单一参数值传递给线程函数。
标志 [in]
这些标志控制的执行。此参数可以是一个或多个下列值。
ValueMeaning
WT_EXECUTEDEFAULT
0x00000000By默认情况下,回调函数是排队到非I / O工作线程。
回调函数是一个线程排队使用I / O完成端口,这意味着它们不能执行报警等待。因此,如果I / O完成并产生的APC中,APC可能会无限期地等待,因为没有保证线程将进入一个可报警等待状态完成后的回调。
WT_EXECUTEINIOTHREAD
0x00000001The回调函数是排队一个I / O工作线程。此线程执行一个报警等待。这是效率较低,因此这个标志应该只会在回调产生的装甲运兵车到当前线程和APC之后应线程返回到线程池执行。
回调函数是作为的APC队列。一定要解决重入问题,如果该函数执行一个可报警等待操作。
WT_EXECUTEINPERSISTENTTHREAD
0x00000080The回调函数是一个线程排队从未终止。它不能保证在同一线程是每次使用。这个标志应该只用于短期任务,也可能影响到其他定时器操作。
请注意,目前没有工作线程是真正持久的,虽然工作线程不终止,如果有任何挂起的I / O请求。
WT_EXECUTELONGFUNCTION
0x00000010The回调函数可以执行一个漫长的等待。此标志帮助系统,以决定是否应该创建一个新线程。
WT_TRANSFER_IMPERSONATION
0x00000100Callback功能将使用当前的访问令牌,无论是过程或模拟令牌。如果此标志没有被指定,回调函数只执行进程令牌。
Windows XP/2000操作系统:这个标志是,直到Windows XP SP2和Windows Server 2003的支持。
返回值
如果函数成功,返回值为非零。
如果函数失败,返回值是零。为了获得更多错误信息,调用GetLastError。
备注
如果在DLL中函数是排队工作线程,请确保已完成的功能之前执行的DLL卸载。
默认情况下,线程池有512个进程的最大线程。为了提高队列限制,使用WT_SET_MAX_THREADPOOL_THREAD宏定义在WINNT.H。
#define WT_SET_MAX_THREADPOOL_THREADS(Flags,Limit) \\
((Flags)|=(Limit)<<16)
使用在调用这个宏QueueUserWorkItem指定flags参数。该宏的参数所需的旗帜和新的限制,最多(2“”16)-1线程。然而,队列的大小受到内核的大小分页池。请注意您的应用程序可以通过保持改善的辅助线程数量少的表现。
要编译的应用程序使用此功能,定义_WIN32_WINNT为0x0500或更高版本。有关详细信息,请参阅使用Windows头。
要求:
最低支持:client-Windows 2000专业版
最低支持server-Windows 2000服务器
HeaderWinbase.h(头文件:winuser.h)
LibraryKernel32.lib
DLLKernel32.dll
参见
进程和线程函数
线程池
ThreadProc
如果有任何问题和意见,请发送给微软(wsddocfb@microsoft.com)
生成日期:2009年8月27日
==英文原文==QueueUserWorkItem Function
Queues a work item to a worker thread in the thread pool .
Syntax
C++
BOOL WINAPI QueueUserWorkItem(
__in LPTHREAD_START_ROUTINE Function,
__in_opt PVOID Context,
__in ULONG Flags
);
Parameters
Function [in]
A pointer to the application-defined callback function of type LPTHREAD_START_ROUTINE to be executed by the thread in the thread pool. This value represents the starting address of the thread. This callback function must not call the TerminateThread function.
For more information, see ThreadProc .
Context [in, optional]
A single parameter value to be passed to the thread function.
Flags [in]
The flags that control execution. This parameter can be one or more of the following values.
ValueMeaning
WT_EXECUTEDEFAULT
0x00000000By default, the callback function is queued to a non-I/O worker thread.
The callback function is queued to a thread that uses I/O completion ports, which means they cannot perform an alertable wait. Therefore, if I/O completes and generates an APC, the APC might wait indefinitely because there is no guarantee that the thread will enter an alertable wait state after the callback completes.
WT_EXECUTEINIOTHREAD
0x00000001The callback function is queued to an I/O worker thread. This thread performs an alertable wait. This is less efficient, so this flag should be used only if the callback generates APCs to the current thread and the APC should be executed after the thread returns to the thread pool.
The callback function is queued as an APC. Be sure to address reentrancy issues if the function performs an alertable wait operation.
WT_EXECUTEINPERSISTENTTHREAD
0x00000080The callback function is queued to a thread that never terminates. It does not guarantee that the same thread is used each time. This flag should be used only for short tasks or it could affect other timer operations.
Note that currently no worker thread is truly persistent, although worker threads do not terminate if there are any pending I/O requests.
WT_EXECUTELONGFUNCTION
0x00000010The callback function can perform a long wait. This flag helps the system to decide if it should create a new thread.
WT_TRANSFER_IMPERSONATION
0x00000100Callback functions will use the current access token, whether it is a process or impersonation token. If this flag is not specified, callback functions execute only with the process token.
Windows XP/2000: This flag is not supported until Windows XP SP2 and Windows Server 2003.

Return Value
If the function succeeds, the return value is nonzero.
If the function fails, the return value is zero. To get extended error information, call GetLastError .
Remarks
If a function in a DLL is queued to a worker thread, be sure that the function has completed execution before the DLL is unloaded.
By default, the thread pool has a maximum of 512 threads per process. To raise the queue limit, use the WT_SET_MAX_THREADPOOL_THREAD macro defined in Winnt.h.
#define WT_SET_MAX_THREADPOOL_THREADS(Flags,Limit) \\
((Flags)|=(Limit)<<16)
Use this macro in the call to QueueUserWorkItem to specify the Flags parameter. The macro parameters are the desired flags and the new limit, up to (2<<16)-1 threads. However, the size of the queue is limited by the size of the kernel nonpaged pool. Note that your application can improve its performance by keeping the number of worker threads low.
To compile an application that uses this function, define _WIN32_WINNT as 0x0500 or later. For more information, see Using the Windows Headers .
Requirements
Minimum supported clientWindows 2000 Professional
Minimum supported serverWindows 2000 Server
HeaderWinbase.h (include Windows.h)
LibraryKernel32.lib
DLLKernel32.dll
See Also
Process and Thread Functions
Thread Pooling
ThreadProc
Send comments about this topic to Microsoft
Build date: 8/27/2009
==原始网址==http://msdn.microsoft.com/en-us/library/ms684957(VS.85).aspx\n
随便看

 

windows api函数参考手册包含2258条windows api函数文档,详细介绍nodejs、java、rust调用windows api的方法技巧,是学习windows api编程的入门中文文档。

 

Copyright © 2004-2023 Winrtm.com All Rights Reserved
京ICP备2021023879号-40 更新时间:2024/10/6 11:26:11