Sha256: 135951ae19b6e79a12191e0f5c1df68c0593e8ed67ca308e5d5986d65e58efe2
Contents?: true
Size: 1.31 KB
Versions: 1
Compression:
Stored size: 1.31 KB
Contents
include_class "foxtrot.Worker" include_class "foxtrot.Job" module Jimpanzee # Module that contains methods and classes used to take care of background # task processing. Primarily this is the repaint_while method. module TaskProcessor # Passes the supplied block to a separate thread and returns the result # of the executed block back to the caller. This should be utilized for long- # running tasks that ought not tie up the Swing Event Dispatch Thread. # Passing a block to this method will allow the GUI to remain responsive # (and repaint), while the long-running task is executing. def repaint_while(&task) runner = Runner.new(&task) Worker.post(runner) end def on_edt(&task) if javax.swing.SwingUtilities.event_dispatch_thread? javax.swing.SwingUtilities.invoke_later Runnable.new(task) else javax.swing.SwingUtilities.invoke_and_wait Runnable.new(task) end end class Runner < Job def initialize(&proc) @proc = proc end def run @proc.call end end class Runnable include Java::java::lang::Runnable def initialize(explicit_block=nil, &block) @block = explicit_block || block end def run @block.call end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
Neurogami-jimpanzee-1.0.3.4 | lib/jimpanzee/task_processor.rb |