engstrand-config / dwl-guile

Dynamic tiling Wayland compositor configurable in Guile Scheme, based on dwl and libguile - now with a REPL!
Other
97 stars 5 forks source link

Use Guile Futures for executing user actions #29

Closed Frewacom closed 1 year ago

Frewacom commented 1 year ago

Guile Futures allows us to evaluate expressions in a threaded environment without the large overhead cost of spawning threads. This would prevent any issues with user actions blocking the main thread of dwl-guile, removing the need for something like eval-async.

Frewacom commented 1 year ago

I did some experimenting with this and realised that it is not quite this simple. Calling dwl-guile bindings from futures can cause really weird behaviour because of it not being executed in the main thread. If this binding does something that affects the rendering in dwl, the result can be UB.

Commit 5d9211c prevents thread safety issues in eval-async, and also renames it dwl:run-async for consistency. However, the solution is nowhere near fast enough to be used for all user bindings, and the extra overhead is not at all worth it.