Comments (8)
On Windows, you should use the default "WinAPI" driver. It will use MsgWaitForMultipleObjectsEx
for its event loop and calls TranslateMessage
/DispatchMessage
, so that all window messages are dispatched to their window procedure as usual.
If you need any advanced message processing, such as classical dialog handling (IsDialogMessage
), this would need an additional message hook API, but that would be quick to add.
from eventcore.
It will use MsgWaitForMultipleObjectsEx for its event loop and calls TranslateMessage/DispatchMessage, so that all window messages are dispatched to their window procedure as usual.
I understand that from the source code easily. But I can't realize what API should I use to add a callback, the event driver has the individual driver features like sockets
, pipes
etc. In X11 I use sockets
and waitForData
, what one of these features should I use in Windows? I'm a linux user in general so some obvious things can elude me.
from eventcore.
This is done via the window procedure, which is set using RegisterClass
(WNDCLASS.lpfnWndProc
member). Whenever a window is then created with that particular class name, the window procedure will be called for each message that goes to the window (done by DispatchMessage
).
from eventcore.
Ok, I see. So eventcore encapsulates native windows message loop. But when I register a class and create the window, eventDriver exits the event loop because it has zero waiters. So I need to do something more...
from eventcore.
I added a dummy timer and the native window works as expected except on closing the window event loop continue to work because of the dummy timer. Probably better would be to create a dummy event and then sending it on WM_DESTROY message to gracefully exit of event loop. Is it right (ideomatic to eventcore) approach?
from eventcore.
Now I create an event and trigger it on WM_DESTROY. It works but I get:
Warning: Event handles leaked at driver shutdown.
But as I can see the event callback is removed on triggering and eventcore does not provide API to remove an event manually. How to exit the event loop gracefully?
from eventcore.
Interesting, I never came across this issue, apparently because vibe-core starts to wait for an event (eventdriver.events
) as soon as its event loop starts. That event is used for other threads to signal a manual event loop exit. So creating an event, calling wait
on it and then cancelWait
/releaseRef
after the window got closed should work properly.
I wonder if that should be something to document as a recommended way to handle windows, or if there should rather be a Windows-specific API addition, such as exposing addWaiter
/removeWaiter
.
from eventcore.
releaseRef
is what I need. Currently I think that custom event is ideomatic way to achive the goal, no need to expose addWaiter/removeWaiter
they should belong to private API.
from eventcore.
Related Issues (20)
- Implement an opt-in performance mode for the Posix process driver HOT 1
- SIGPIPE on send
- Compilation fails on FreeBSD 12.0 HOT 7
- Is EINTR handled on POSIX? HOT 1
- Release v0.8.49 broke dlang's Buildkite CI HOT 2
- What's the validation counter used for?
- code duplication within version block below. HOT 2
- dub produces error on FreeBSD 12.1-RELEASE-p10 HOT 2
- Do not call `AA.remove` from finalizer HOT 4
- android pie compile error HOT 1
- Timer callback resets on every firing and should be rearmed to continue HOT 1
- Use io_uring where sensible HOT 1
- Possible s_driver leaking path HOT 4
- Creating and waiting on timers causes GC allocation every time - expected?
- Issue with installing vibe.d on android for termux HOT 2
- Implement support for DNS resolution via `org.freedesktop.resolve1`
- Building eventcore failing on FreeBSD 13.0-RELEASE
- waitForData is not implemented for Windows
- About io_uring support ;)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from eventcore.