Class: Swt::EventLoop
- Inherits:
-
Object
- Object
- Swt::EventLoop
- Defined in:
- lib/swt/event_loop.rb
Instance Method Summary collapse
-
#initialize ⇒ EventLoop
constructor
A new instance of EventLoop.
-
#start ⇒ Object
Begins the SWT event loop.
-
#stop ⇒ Object
Halts the SWT event loop.
-
#yield_until ⇒ Object
Lets the even loop run until block returns false.
Constructor Details
#initialize ⇒ EventLoop
Returns a new instance of EventLoop.
4 5 6 |
# File 'lib/swt/event_loop.rb', line 4 def initialize @running = false end |
Instance Method Details
#start ⇒ Object
Begins the SWT event loop. Blocks.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/swt/event_loop.rb', line 9 def start @running = true @display = Swt.display while @running and not @display.disposed? begin unless read = @display.read_and_dispatch @display.sleep end rescue java.lang.Throwable => e puts "Error in Event Loop:" p e puts e.backtrace end end @display.dispose end |
#stop ⇒ Object
Halts the SWT event loop.
32 33 34 |
# File 'lib/swt/event_loop.rb', line 32 def stop @running = false end |
#yield_until ⇒ Object
Lets the even loop run until block returns false
27 28 29 |
# File 'lib/swt/event_loop.rb', line 27 def yield_until @display.read_and_dispatch until yield end |