X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=lib%2Fsup%2Fpoll.rb;h=2dd915011c26c8310a0290f5499c0f18b80e9d94;hb=cf64e00296eb43cb66afba5a5ba4fa95aaced6fb;hp=2faadfe87634d6f1d31bf3ebd0e870d2fa19bb06;hpb=de801b1dba30897ac189b3b3b6ca589fdb22a23e;p=sup diff --git a/lib/sup/poll.rb b/lib/sup/poll.rb index 2faadfe..2dd9150 100644 --- a/lib/sup/poll.rb +++ b/lib/sup/poll.rb @@ -19,12 +19,13 @@ EOS HookManager.register "after-poll", <", :hidden => true) { PollMode.new } + b, new = BufferManager.spawn_unless_exists("", :hidden => true) { PollMode.new } + b end def poll @@ -55,14 +57,14 @@ EOS BufferManager.flash "No new messages." end - HookManager.run "after-poll", :num => num, :num_inbox => numi, :from_and_subj => from_and_subj, :from_and_subj_inbox => from_and_subj_inbox + HookManager.run "after-poll", :num => num, :num_inbox => numi, :from_and_subj => from_and_subj, :from_and_subj_inbox => from_and_subj_inbox, :num_inbox_total_unread => lambda { Index.num_results_for :labels => [:inbox, :unread] } @polling = false [num, numi] end def start - @thread = Redwood::reporting_thread do + @thread = Redwood::reporting_thread("periodic poll") do while true sleep DELAY / 2 poll if @last_poll.nil? || (Time.now - @last_poll) >= DELAY @@ -156,7 +158,7 @@ EOS HookManager.run "before-add-message", :message => m m = yield(m, offset, entry) or next Index.sync_message m, docid, entry - UpdateManager.relay self, :add, m unless entry + UpdateManager.relay self, :added, m unless entry rescue MessageFormatError => e Redwood::log "ignoring erroneous message at #{source}##{offset}: #{e.message}" end