Bug 572925 - Display.sleep() with timeout
Summary: Display.sleep() with timeout
Status: NEW
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 4.20   Edit
Hardware: PC Linux
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: Platform-SWT-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-04-17 05:36 EDT by Christoph Laeubrich CLA
Modified: 2021-04-17 05:36 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Christoph Laeubrich CLA 2021-04-17 05:36:41 EDT
Currently Display.sleep() waits "until an event is received or it is otherwise awakened" ...

So it can't be used in situations where (beside the UI) there are other flags to check e.g.

while(!someOtherTask.isDone() && !display.isDisposed()) {
	if(!display.readAndDispatch()) {
		display.sleep();
	}
}

because there is no fuarante to be wake up if no event happens (e.g. the loop might hang if the app has no focus and thus no repaints or mouse/key events happen).

For such cases it would be good to have a variant of this to 

Display.sleep(timeout)

where it waits "until an event is received, the given timeout has elapsed, or it is otherwise awakened."

no precise timing is required here of course just some kind of upper bound. At least on GTK it seems there is already a wait with timout (50ms) happening.