网站首页  词典首页

请输入您要查询的函数:

 

术语 createiocompletionport
释义 CreateIoCompletionPort
语法:
C++
HANDLE WINAPI CreateIoCompletionPort(
__in HANDLE FileHandle,
__in_opt HANDLE ExistingCompletionPort,
__in ULONG_PTR CompletionKey,
__in DWORD NumberOfConcurrentThreads
);
CreateIoCompletionPort函数
创建一个输入/输出(I / O)的完成端口和一个指定的文件句柄联系,或创建一个I / O完成端口,尚未有相关的文件句柄,从而在以后的联系。
联系到一个I / O完成端口允许进程收到的完成通知异步I / O操作,涉及该文件处理的一个打开的文件句柄实例。
注意:
文件句柄一词用在这里是指作为一个系统的抽象表示一个重叠I / O端点,不仅是一个磁盘上的文件。任何系统的支持对象重叠I如网络终端,TCP套接字命名管道,/ O型,和邮件插槽,可作为文件句柄使用。有关其他信息,请参见备注部分。
参数
文件句柄 [in]
一个开放的文件句柄或INVALID_HANDLE_VALUE。
句柄必须是支持的对象重叠I / O
如果提供了一个句柄,它已开放重叠I / O完成。例如,您必须指定FILE_FLAG_OVERLAPPED标志使用CreateFile函数以获取处理。
如果INVALID_HANDLE_VALUE指定的函数创建一个I / O完成端口没有关联的文件处理。在这种情况下,ExistingCompletionPort参数必须是NULL并且完成键参数被忽略。
ExistingCompletionPort [中,可选]
句柄到现有的I / O完成端口或NULL。
如果此参数指定一个现有的I / O完成端口,它的功能联系与处理参数指定的文件句柄。该函数返回现有我处理/ O完成端口如果成功的话,它不创建一个新的I / O完成端口。
如果该参数为NULL,则函数创建一个新的I / O完成端口,如果该文件句柄参数是有效的,与新的I / O完成端口关联。否则,没有文件句柄发生关联。该函数返回的句柄新的I / O完成端口如果成功。
完成键 [in]
每柄用户定义的完成,关键是每个所列/输出为指定的文件句柄完成数据包。有关详细信息,请参见备注部分。
NumberOfConcurrentThreads [in]
线程的最大数量的操作系统可以允许同时处理的I / O完成端口I / O完成包。此参数被忽略,如果ExistingCompletionPort参数不是NULL。
如果此参数为0,系统允许尽可能多线程同时运行,因为在系统处理器。
返回值
如果函数成功,返回值是处理到一个I / O完成端口:
如果ExistingCompletionPort参数是NULL,则返回值是一个新的处理。
如果ExistingCompletionPort参数是一个有效的I / O完成端口句柄,返回值是相同的处理。
如果该文件句柄参数是一个有效的处理,该文件处理正与返回的I / O完成端口相关联。
如果函数失败,返回值为NULL。为了获得更多错误信息,调用GetLastError函数。
备注
在I / O系统可以指示发送I / O完成通知包I / O完成端口,他们在那里排队。该CreateIoCompletionPort函数提供了此功能。
一个I / O完成端口,其处理过程与创建它,而不是进程之间共享的有关本人。然而,一个是可共享的处理线程之间在同一进程中。
CreateIoCompletionPort可以使用三种不同的模式:
只创建一个I / O完成端口没有关联的文件处理。
副现有的I / O的文件句柄完成端口。
在执行一次调用都创建和协会。
要创建无关联它的I / O完成端口,设置文件句柄参数INVALID_HANDLE_VALUE的ExistingCompletionPort参数为NULL,以及完成键参数设置为零(这是在这种情况下被忽略)。设置NumberOfConcurrentThreads参数为新的I / O完成端口,或默认为零系统(所需的处理器数量并发值)。
句柄传递的文件句柄参数可以是任何处理,支持重叠I / O最常见的,这是一个句柄开幕CreateFile使用FILE_FLAG_OVERLAPPED标志(例如功能,文件,邮件槽,水管)。插座,如其他职能创建的对象也可以与一个I / O完成端口。如需使用套接字的例子,见AcceptEx。句柄可以只有一个I / O完成端口,该协会后作出相关的处理仍然与该I / O完成端口相关直到它被关闭。
欲了解更多的I / O完成端口的理论,使用信息和相关职能,看到的I / O完成端口。
多个文件句柄可以用一个I / O相关通过调用相同的I / O完成端口处理在ExistingCompletionPort参数和不同的文件处理的文件句柄参数每次CreateIoCompletionPort多次完成端口。
使用完成键参数,以帮助您的应用程序跟踪的I / O操作完成。此值不使用CreateIoCompletionPort功能的控制,相反,它是连接到文件处理参数中指定的文件句柄在协会的I / O完成端口的时间。这完成的关键应该是唯一的每个文件的处理,并伴随整个过程完成内部排队的文件句柄。正是在GetQueuedCompletionStatus函数调用时返回一个完成包到达。在完成键参数也使用PostQueuedCompletionStatus功能队列自己的专用完成数据包。
经过一个开放的,是与我联系/ O完成端口句柄,例如,它不能用在ReadFileEx或WriteFileEx功能,因为这些功能有自己的异步I / O机制。
最好不要共享文件与I / O相关通过使用继承或处理的DuplicateHandle函数调用完成端口处理。操作进行重复处理等产生完成通知。仔细考虑建议。
在I / O完成端口处理和每一个文件与特定的I / O完成端口相关处理被称为向我提/ O完成端口。在/ O完成端口被释放时,没有更多的引用它我。因此,所有这些必须妥善处理关闭释放的I / O完成端口及其相关的系统资源。当这些条件得到满足,关闭I / O完成端口句柄通过调用CloseHandle函数。
要求:
最低支持:client-Windows 2000专业版
最低支持server-Windows 2000服务器
HeaderWinBase.h(头文件:winuser.h)
LibraryKernel32.lib
DLLKernel32.dll
参见
专题概述
文件管理函数
I / O完成端口
使用Windows头
Windows套接字2

函数
AcceptEx
CreateFile
DuplicateHandle
GetQueuedCompletionStatus
GetQueuedCompletionStatusEx
PostQueuedCompletionStatus
ReadFileEx
WriteFileEx
如果有任何问题和意见,请发送给微软(wsddocfb@microsoft.com)
生成日期:2009年9月3日
==英文原文==CreateIoCompletionPort Function
Creates an input/output (I/O) completion port and associates it with a specified file handle, or creates an I/O completion port that is not yet associated with a file handle, allowing association at a later time.
Associating an instance of an opened file handle with an I/O completion port allows a process to receive notification of the completion of asynchronous I/O operations involving that file handle.
Note
The term file handle as used here refers to a system abstraction that represents an overlapped I/O endpoint, not only a file on disk. Any system objects that support overlapped I/O—such as network endpoints, TCP sockets, named pipes, and mail slots—can be used as file handles. For additional information, see the Remarks section.
Syntax
C++
HANDLE WINAPI CreateIoCompletionPort(
__in HANDLE FileHandle,
__in_opt HANDLE ExistingCompletionPort,
__in ULONG_PTR CompletionKey,
__in DWORD NumberOfConcurrentThreads
);
Parameters
FileHandle [in]
An open file handle or INVALID_HANDLE_VALUE.
The handle must be to an object that supports overlapped I/O.
If a handle is provided, it has to have been opened for overlapped I/O completion. For example, you must specify the FILE_FLAG_OVERLAPPED flag when using the CreateFile function to obtain the handle.
If INVALID_HANDLE_VALUE is specified, the function creates an I/O completion port without associating it with a file handle. In this case, the ExistingCompletionPort parameter must be NULL and the CompletionKey parameter is ignored.
ExistingCompletionPort [in, optional]
A handle to an existing I/O completion port or NULL.
If this parameter specifies an existing I/O completion port, the function associates it with the handle specified by the FileHandle parameter. The function returns the handle of the existing I/O completion port if successful; it does not create a new I/O completion port.
If this parameter is NULL, the function creates a new I/O completion port and, if the FileHandle parameter is valid, associates it with the new I/O completion port. Otherwise no file handle association occurs. The function returns the handle to the new I/O completion port if successful.
CompletionKey [in]
The per-handle user-defined completion key that is included in every I/O completion packet for the specified file handle. For more information, see the Remarks section.
NumberOfConcurrentThreads [in]
The maximum number of threads that the operating system can allow to concurrently process I/O completion packets for the I/O completion port. This parameter is ignored if the ExistingCompletionPort parameter is not NULL.
If this parameter is zero, the system allows as many concurrently running threads as there are processors in the system.
Return Value
If the function succeeds, the return value is the handle to an I/O completion port:
If the ExistingCompletionPort parameter was NULL, the return value is a new handle.
If the ExistingCompletionPort parameter was a valid I/O completion port handle, the return value is that same handle.
If the FileHandle parameter was a valid handle, that file handle is now associated with the returned I/O completion port.
If the function fails, the return value is NULL. To get extended error information, call the GetLastError function.
Remarks
The I/O system can be instructed to send I/O completion notification packets to I/O completion ports, where they are queued. The CreateIoCompletionPort function provides this functionality.
An I/O completion port and its handle are associated with the process that created it and is not shareable between processes. However, a single handle is shareable between threads in the same process.
CreateIoCompletionPort can be used in three distinct modes:
Create only an I/O completion port without associating it with a file handle.
Associate an existing I/O completion port with a file handle.
Perform both creation and association in a single call.
To create an I/O completion port without associating it, set the FileHandle parameter to INVALID_HANDLE_VALUE, the ExistingCompletionPort parameter to NULL, and the CompletionKey parameter to zero (which is ignored in this case). Set the NumberOfConcurrentThreads parameter to the desired concurrency value for the new I/O completion port, or zero for the default (the number of processors in the system).
The handle passed in the FileHandle parameter can be any handle that supports overlapped I/O. Most commonly, this is a handle opened by the CreateFile function using the FILE_FLAG_OVERLAPPED flag (for example, files, mail slots, and pipes). Objects created by other functions such as socket can also be associated with an I/O completion port. For an example using sockets, see AcceptEx . A handle can be associated with only one I/O completion port, and after the association is made, the handle remains associated with that I/O completion port until it is closed.
For more information on I/O completion port theory, usage, and associated functions, see I/O Completion Ports .
Multiple file handles can be associated with a single I/O completion port by calling CreateIoCompletionPort multiple times with the same I/O completion port handle in the ExistingCompletionPort parameter and a different file handle in the FileHandle parameter each time.
Use the CompletionKey parameter to help your application track which I/O operations have completed. This value is not used by CreateIoCompletionPort for functional control; rather, it is attached to the file handle specified in the FileHandle parameter at the time of association with an I/O completion port. This completion key should be unique for each file handle, and it accompanies the file handle throughout the internal completion queuing process. It is returned in the GetQueuedCompletionStatus function call when a completion packet arrives. The CompletionKey parameter is also used by the PostQueuedCompletionStatus function to queue your own special-purpose completion packets.
After an instance of an open handle is associated with an I/O completion port, it cannot be used in the ReadFileEx or WriteFileEx function because these functions have their own asynchronous I/O mechanisms.
It is best not to share a file handle associated with an I/O completion port by using either handle inheritance or a call to the DuplicateHandle function. Operations performed with such duplicate handles generate completion notifications. Careful consideration is advised.
The I/O completion port handle and every file handle associated with that particular I/O completion port are known as references to the I/O completion port. The I/O completion port is released when there are no more references to it. Therefore, all of these handles must be properly closed to release the I/O completion port and its associated system resources. After these conditions are satisfied, close the I/O completion port handle by calling the CloseHandle function.
Requirements
Minimum supported clientWindows 2000 Professional
Minimum supported serverWindows 2000 Server
HeaderWinBase.h (include Windows.h)
LibraryKernel32.lib
DLLKernel32.dll
See Also
Overview Topics
File Management Functions
I/O Completion Ports
Using the Windows Headers
Windows Sockets 2

Functions
AcceptEx
CreateFile
DuplicateHandle
GetQueuedCompletionStatus
GetQueuedCompletionStatusEx
PostQueuedCompletionStatus
ReadFileEx
WriteFileEx
Send comments about this topic to Microsoft
Build date: 9/3/2009
==原始网址==http://msdn.microsoft.com/en-us/library/aa363862(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 13:25:52