commit 6578c2141763fcf05f63c42eab0908123ffcce3f
parent 92014b9a0ac23eab5f36a2f9276ca4047200dd46
Author: William Morgan <wmorgan-sup@masanjin.net>
Date: Tue, 24 Mar 2009 20:21:21 -0700
background-threadify message state saving
Diffstat:
1 file changed, 14 insertions(+), 8 deletions(-)
diff --git a/lib/sup/modes/thread-index-mode.rb b/lib/sup/modes/thread-index-mode.rb
@@ -68,6 +68,8 @@ EOS
UpdateManager.register self
+ @save_thread_mutex = Mutex.new
+
@last_load_more_size = nil
to_load_more do |size|
next if @last_load_more_size == 0
@@ -386,14 +388,18 @@ EOS
end
def save
- BufferManager.say("Saving contacts...") { ContactManager.instance.save }
- dirty_threads = @mutex.synchronize { (@threads + @hidden_threads.keys).select { |t| t.dirty? } }
- return if dirty_threads.empty?
-
- BufferManager.say("Saving threads...") do |say_id|
- dirty_threads.each_with_index do |t, i|
- BufferManager.say "Saving modified thread #{i + 1} of #{dirty_threads.length}...", say_id
- t.save Index
+ Redwood::reporting_thread("saving thread") do
+ @save_thread_mutex.synchronize do
+ BufferManager.say("Saving contacts...") { ContactManager.instance.save }
+ dirty_threads = @mutex.synchronize { (@threads + @hidden_threads.keys).select { |t| t.dirty? } }
+ return if dirty_threads.empty?
+
+ BufferManager.say("Saving threads...") do |say_id|
+ dirty_threads.each_with_index do |t, i|
+ BufferManager.say "Saving modified thread #{i + 1} of #{dirty_threads.length}...", say_id
+ t.save Index
+ end
+ end
end
end
end