lib/njiiri/mpd.rb
def pending
    @mutex.synchronize do
      blocks = @@callbacks.collect {|n, t, cb| @tasks[n] }.compact
      @tasks.clear
      return blocks
    end
  end
# when the librmpd callback thread runs anything below, we don't
# want it to call into GTK (which is a pain to make thread-safe. You
# could do it; you could also eat soup with a fork. A good fork). So
# this stuff just queues up some blocks to be actually executed in
# the GTK thread. This allows us to cheat (I mean, optimize) a
# little by only responding to the last event of a given type (in
# the "slot", which is simply not a list) if several come down the
# wire between runs of our timer back in the main loop.
#
# Still a botch, but I've no time to write a new MPD library. Yet.
when the librmpd callback thread runs anything below, we don't
want it to call into GTK (which is a pain to make thread-safe. You
could do it; you could also eat soup with a fork. A good fork). So
this stuff just queues up some blocks to be actually executed in
the GTK thread. This allows us to cheat (I mean, optimize) a
little by only responding to the last event of a given type (in
the "slot", which is simply not a list) if several come down the
wire between runs of our timer back in the main loop.

Still a botch, but I've no time to write a new MPD library. Yet.
when the librmpd callback thread runs anything below we don ' t want it to call into GTK ( which is a pain to make thread - safe . You could do it ; you could also eat soup with a fork . A good fork ) . So this stuff just queues up some blocks to be actually executed in the GTK thread . This allows us to cheat ( I mean optimize ) a little by only responding to the last event of a given type ( in the " slot " which is simply not a list ) if several come down the wire between runs of our timer back in the main loop . Still a botch but I ' ve no time to write a new MPD library . Yet .
def pending
    @mutex.synchronize do
      blocks = @@callbacks.collect {|n, t, cb| @tasks[n] }.compact
      @tasks.clear
      return blocks
    end
  end
def pending @mutex . synchronize do blocks = @@callbacks . collect { | n , t , cb | @tasks [ n ] } . compact @tasks . clear return blocks end end
when the librmpd callback thread runs anything below, we don't
want it to call into GTK (which is a pain to make thread-safe.
when the librmpd callback thread runs anything below we don ' t want it to call into GTK ( which is a pain to make thread - safe .