Skip to content

x11: thread safe replacement for XNextEvent#782

Merged
august64 merged 2 commits intorust-windowing:masterfrom
rikusalminen:waitevent
Feb 24, 2019
Merged

x11: thread safe replacement for XNextEvent#782
august64 merged 2 commits 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_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 #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
@jansol
Copy link
Copy Markdown

jansol commented Feb 13, 2019

@francesca64 ping (fixed version of #781 )

@august64 august64 added the DS - x11 Affects the X11 backend, or generally free Unix platforms label Feb 23, 2019
Copy link
Copy Markdown
Member

@august64 august64 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the delay! Looks great, and I'm happy to see this long-standing issue fixed! (I really appreciate the informative comments, too.)

I don't currently have access to a Linux box, so could @mitchmindtree / @vberger / etc. test that this works as expected?

@elinorbgr
Copy link
Copy Markdown
Contributor

I tested some of the winit examples with this on x11, and it seems to work smoothly.

@august64 august64 merged commit 9ea2810 into rust-windowing:master Feb 24, 2019
elinorbgr pushed a commit to elinorbgr/winit that referenced this pull request Apr 7, 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_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
elinorbgr pushed a commit to elinorbgr/winit that referenced this pull request Apr 7, 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_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
felixrabe pushed a commit to felixrabe/winit that referenced this pull request Jun 30, 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_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
kosyak pushed a commit to kosyak/winit that referenced this pull request Jul 10, 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_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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

DS - x11 Affects the X11 backend, or generally free Unix platforms

Development

Successfully merging this pull request may close these issues.

4 participants