Sha256: 98b44c9a069292023f424b41990bc73f30346f2ad3cfa34f8d3f8286d66b63e9

Contents?: true

Size: 599 Bytes

Versions: 5

Compression:

Stored size: 599 Bytes

Contents

# encoding: ascii-8bit

require "monitor"

module Gtk
  GTK_PENDING_BLOCKS = []
  GTK_PENDING_BLOCKS_LOCK = Monitor.new

  def Gtk.queue &block
    GTK_PENDING_BLOCKS_LOCK.synchronize do
      GTK_PENDING_BLOCKS << block
    end
  end

  def Gtk.main_iteration_with_queue
      GTK_PENDING_BLOCKS_LOCK.synchronize do
        for block in GTK_PENDING_BLOCKS
          block.call
        end
        GTK_PENDING_BLOCKS.clear
      end
    Gtk.main_iteration while Gtk.events_pending
  end
end

module EM
  def self.gtk_main
    EM.add_periodic_timer(0.001) { Gtk.main_iteration_with_queue }
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
bitcoin-ruby-0.0.6 lib/bitcoin/gui/em_gtk.rb
bitcoin-ruby-0.0.5 lib/bitcoin/gui/em_gtk.rb
bitcoin-ruby-0.0.4 lib/bitcoin/gui/em_gtk.rb
bitcoin-ruby-0.0.3 lib/bitcoin/gui/em_gtk.rb
bitcoin-ruby-0.0.2 lib/bitcoin/gui/em_gtk.rb