From: Ramkumar Ramachandra <artagnon@gmail.com>
To: sup-talk <sup-talk@rubyforge.org>
Subject: [sup-talk] [PATCH 2/4] Poll for editor status
Date: Sat, 10 Apr 2010 16:09:04 +0530 [thread overview]
Message-ID: <1270895932-sup-2620@kytes> (raw)
Write a second loop in PollManager to poll and check if the
asynchronously spawned editor has finished. If finished, fire a
callback.
Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
---
lib/sup/poll.rb | 31 ++++++++++++++++++++++++++++++-
1 files changed, 30 insertions(+), 1 deletions(-)
diff --git a/lib/sup/poll.rb b/lib/sup/poll.rb
index 582cd4d..0fabb87 100644
--- a/lib/sup/poll.rb
+++ b/lib/sup/poll.rb
@@ -38,6 +38,13 @@ EOS
@poll_sources = nil
@mode = nil
@should_clear_running_totals = false
+
+ # For async editing
+ @editor_thread = nil
+ @edit_in_progress = false
+ @editor_file = nil
+ @edit_mtime = nil
+
clear_running_totals # defines @running_totals
UpdateManager.register self
end
@@ -71,6 +78,20 @@ EOS
[num, numi]
end
+ def poll_editor
+ return if @polling
+ return if not @edit_in_progress
+ @polling = true
+ if @editor_thread.alive?
+ BufferManager.flash "Edit in progress..."
+ else
+ BufferManager.flash "Edit finished!"
+ @edit_in_progress = false
+ ComposeMode.edit_message_callback @editor_file, @editor_mtime
+ end
+ @polling = false
+ end
+
def poll_unusual
return if @polling
@polling = true
@@ -83,8 +104,9 @@ EOS
def start
@thread = Redwood::reporting_thread("periodic poll") do
while true
- sleep DELAY / 2
+ sleep 1
poll if @last_poll.nil? || (Time.now - @last_poll) >= DELAY
+ poll_editor if @last_poll.nil? || (Time.now - @last_poll) >= 2
end
end
end
@@ -192,6 +214,13 @@ EOS
UpdateManager.relay self, :added, m
end
+ def editor_loop_init pthread, file, mtime
+ @editor_thread = pthread
+ @edit_in_progress = true
+ @editor_file = file
+ @editor_mtime = mtime
+ end
+
def handle_idle_update sender, idle_since; @should_clear_running_totals = false; end
def handle_unidle_update sender, idle_since; @should_clear_running_totals = true; clear_running_totals; end
def clear_running_totals; @running_totals = {:num => 0, :numi => 0, :loaded_labels => Set.new}; end
--
1.7.0.4
_______________________________________________
sup-talk mailing list
sup-talk@rubyforge.org
http://rubyforge.org/mailman/listinfo/sup-talk
reply other threads:[~2010-04-10 10:41 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1270895932-sup-2620@kytes \
--to=artagnon@gmail.com \
--cc=sup-talk@rubyforge.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox