Skip to content

Instantly share code, notes, and snippets.

@glurp
Created July 21, 2011 17:53
Show Gist options
  • Save glurp/1097754 to your computer and use it in GitHub Desktop.
Save glurp/1097754 to your computer and use it in GitHub Desktop.
thread asynchronous invoker for shoes application
require 'thread'
class Object
def invoke_in_shoes_mainloop(&blk)
return unless defined?($__shoes_app__)
return unless Shoes::App===$__shoes_app__
$__shoes_app__.get_queue().push( blk )
end
end
class Shoes
class App
def get_queue()
@queue=Queue.new if ! defined?(@queue)
@queue
end
def define_async_thread_invoker(period=0.1)
$__shoes_app__=self
@queue=Queue.new if ! defined?(@queue)
every(period) do
while @queue.size>0
instance_eval &@queue.pop
end
end
end
def show_app() # green_shoes/gtk2 stuff...
win.deiconify
win.show
end
def hide_app
win.iconify
win.hide
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment