Class: Sol::Bridge

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/webview/sol.rb

Overview

Bridge is the communication channel between the Dashboard, where all Ruby code is written and executed and the GUI (Web Browser). The Dashboard thread and the GUI thread need to communicate through message passing. The Dashboard cannot directly interfere with the GUI thread.

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Constructor Details

- (Bridge) initialize


Use a LinkedBlockingQueue with max size of 1 to communicate from the ruby script to the GUI. The ruby script will send a message that is consumed by the GUI.




116
117
118
# File 'lib/webview/sol.rb', line 116

def initialize
  @queue = java.util.concurrent::LinkedBlockingQueue.new(1)
end

Instance Attribute Details

- (Object) queue (readonly)

comunication queue



109
110
111
# File 'lib/webview/sol.rb', line 109

def queue
  @queue
end

Instance Method Details

- (Object) send(*message)





124
125
126
# File 'lib/webview/sol.rb', line 124

def send(*message)
  @queue.put(message)
end

- (Object) take





132
133
134
# File 'lib/webview/sol.rb', line 132

def take
  @queue.take()
end