Created
July 21, 2011 17:53
-
-
Save glurp/1097754 to your computer and use it in GitHub Desktop.
thread asynchronous invoker for shoes application
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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