Sha256: 7d02bd4fc3ee9cd4b5fc2ec5d5f8db927fcff52c3496f06e4e45f0f56b45c686

Contents?: true

Size: 575 Bytes

Versions: 1

Compression:

Stored size: 575 Bytes

Contents

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

1 entries across 1 versions & 1 rubygems

Version Path
bitcoin-ruby-0.0.1 lib/bitcoin/gui/em_gtk.rb