Skip to content

x11: thread safe replacement for XNextEvent#781

Closed
rikusalminen wants to merge 1 commit intorust-windowing:masterfrom
rikusalminen:waitevent
Closed

x11: thread safe replacement for XNextEvent#781
rikusalminen wants to merge 1 commit intorust-windowing:masterfrom
rikusalminen:waitevent

Conversation

@rikusalminen
Copy link
Copy Markdown
Contributor

@rikusalminen rikusalminen commented Jan 27, 2019

XNextEvent will block for input while holding the global Xlib mutex.

This will cause a deadlock in even the most trivial multi-threaded
application because OpenGL functions will need to hold the Xlib mutex
too.

Add EventsLoop::poll_one_event and EventsLoop::wait_one_event to provide
thread-safe functions to poll and wait events from the X11 event queue
using unix select(2) and XCheckIfEvent.

This is a somewhat ugly workaround to an ugly problem.

Fixes #779

  • Tested on all platforms changed
  • Added an entry to CHANGELOG.md if knowledge of this change could be valuable to users
  • Updated documentation to reflect any user-facing changes, including notes of platform-specific behavior
  • Created an example program if it would help users understand this functionality

XNextEvent will block for input while holding the global Xlib mutex.

This will cause a deadlock in even the most trivial multi-threaded
application because OpenGL functions will need to hold the Xlib mutex
too.

Add EventsLoop::poll_one_event and EventsLoop::wait_for_input to provide
thread-safe functions to poll and wait events from the X11 event queue
using unix select(2) and XCheckIfEvent.

This is a somewhat ugly workaround to an ugly problem.

Fixes rust-windowing#779
@rikusalminen
Copy link
Copy Markdown
Contributor Author

Whoops, commit message was out of date! I'll post another pull req with fixed commit message.

@august64
Copy link
Copy Markdown
Member

@rikusalminen for future reference, you can just force push to overwrite the old commit message.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants