Can I wait for GUI events — that is, pump a message loop — and on an I/O completion port at the same time? I would like to integrate libuv with the Windows GUI.
Waiting for GUI events and IOCP notifications at once
1k Views Asked by Demi At
1
There are 1 best solutions below
Related Questions in WINDOWS
- how to play a sounds in c# forms?
- Echo behaviour of Microsoft Windows Telnet Client
- Getting error while running spark-shell on my system; pyspark is running fine
- DirectX 9 With No SDK Installed - How To Translate a D3DMATRIX?
- Gradle 8.7 cannot find installed JDK 22 in IntelliJ
- 'IOException: The cloud file provider is not running', when trying to delete 'cloud' folder
- Cannot load modules/mod_dav_svn.so into server
- Issue with launching application after updating ElectronJs to version 28.0.0 on Windows and Linux
- 32-bit applications do not display some files in Windows 10
- 'bun' is not recognized as an internal or external command
- mkssecreenshotmgr taking a screenshot
- Next js installation in windows 7 os
- Can't resize a partition using Mini Tool?
- Is there any way to set a printer as default according with Active Directory Policy Security Group and PC hostname?
- Electron Printing not working on Windows (Works on Mac)
Related Questions in IOCP
- What is the purpose of this statement?
- How to use ConnectEx(mswsock.h) with RIO(Registered I/O)?
- Does GetQueuedCompletionStatusEx performs load balancing when multiple threads are waiting on the same IOCP?
- C++ IOCP Client And Server Sending and Receiving data problem
- .NET 6 long busy wait on IO operations instantly completes when memory dump is taken
- Debugging a nasty Lock Contention issue in ASP.NET Core MVC
- WSARecvFrom unclear return behavior with IOCP (UDP)
- LIFO ordering of return from GetQueuedCompletionStatus
- IOCP Threads and GetQueuedCompletionStatus
- Setting IOCP Threads min/max in .NET core - verifying the effect of the change
- How to bind multi IOCP handle to a single file handle to split read / write request?
- Queueuserworkitem vs TrySubmitThreadpoolCallback
- Why we need `CreateThreadpoolIo` and `StartThreadpoolIo` for IOCP?
- IOCP when read is busy?
- How to deal with many incoming UDP packets when the server has only 1 UDP socket?
Related Questions in MESSAGE-LOOP
- How does Win32 API PeekMessage function work
- C++ How to allowing for Low Level Mouse callback to get called in a loop/ when wait for input
- Translate sequences of virtual keycodes into the resulting character message
- Initializing the COM library in apartment threaded mode in a thread with no message loop
- Necessity of testing key value before calling IsDialogMessage
- MFC CListView how to prevent search & auto-selection when user types letters?
- How to invoke into message loop after Application.Run()
- Why is DestroyWindow blocked?
- How to dispatch messages for multiple dialogs in an ATL exe
- How to quit/break from windows message loop in console app and deferences from windows desktop app?
- Why does the win32 message loop stop working when threaded?
- Difficulty displaying "login" and "main" forms correctly
- CefSharp.WinForms Drag and Drop messageloop override
- Is it possible to create a message loop without creating a window in C++
- Why Is PostQuitMessage Necessary
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular # Hahtags
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
There are two solutions that I know of. One works on all versions of Windows, but involves multiple threads. The other is faster, but only supports Windows 10+ (thank you @RbMm for this fact).
Another thread calls
GetQueuedCompletionStatusExin a loop, and sends messages to the main thread withSendMessage. The main thread reads the messages from it's message loop, notes the custom message type, and dispatches the I/O completions.This solution works on all versions of Windows, but is slower. However, if one is willing to trade latency for throughput, one can increase the
GetQueuedCompletionStatusExreceive buffer to recover nearly the same throughput as the second solution. For best performance, both threads should use the same CPU, to avoid playing cache ping-pong with the I/O completions.The main thread uses
MsgWaitForMultipleObjectsExto wait for the completion port to be signaled or user input to arrive. Once it is signaled, the main thread callsGetQueuedCompletionStatusExwith a zero timeout.This assumes that an IOCP that is used by only one thread becomes signaled precisely when an I/O completion arrives. This is only true on Windows 10 and up. Otherwise, you will busyloop, since the IOCP will always be signaled. On systems that support this method, it should be faster, since it reduces scheduling overhead.