From: Eugene Marinelli <eugeneiiim@gmail.com>
To: Rich Lane <rlane@club.cc.cmu.edu>
Cc: sup-talk@rubyforge.org
Subject: Re: [sup-talk] [PATCH 2/4] async thread indexing
Date: Sun, 8 Nov 2009 22:02:07 -0800 [thread overview]
Message-ID: <69d60e3a0911082202t31561f18mf5e24dda7a108b58@mail.gmail.com> (raw)
In-Reply-To: <1257399921-26813-2-git-send-email-rlane@club.cc.cmu.edu>
> - Index.save_thread t
> + Index.save_thread_async t
Where is the "save_thread_async" function?
In patch 3/4, this looks like a syntax error:
> - end
> + threads.each { |t| Index.save_thread async t }
> end
- Eugene Marinelli
On Wed, Nov 4, 2009 at 9:45 PM, Rich Lane <rlane@club.cc.cmu.edu> wrote:
> ---
> bin/sup | 2 ++
> lib/sup/index.rb | 26 +++++++++++++++++++++++++-
> lib/sup/modes/thread-index-mode.rb | 2 +-
> 3 files changed, 28 insertions(+), 2 deletions(-)
>
> diff --git a/bin/sup b/bin/sup
> index 78c396a..910ff12 100755
> --- a/bin/sup
> +++ b/bin/sup
> @@ -142,6 +142,7 @@ Index.lock_interactively or exit
> begin
> Redwood::start
> Index.load
> + Index.start_sync_worker unless $opts[:no_threads]
>
> $die = false
> trap("TERM") { |x| $die = true }
> @@ -335,6 +336,7 @@ ensure
>
> HookManager.run "shutdown"
>
> + Index.stop_sync_worker
> Redwood::finish
> stop_cursing
> Redwood::Logger.remove_all_sinks!
> diff --git a/lib/sup/index.rb b/lib/sup/index.rb
> index 5d8d714..1131ec7 100644
> --- a/lib/sup/index.rb
> +++ b/lib/sup/index.rb
> @@ -28,6 +28,8 @@ class BaseIndex
> def initialize dir=BASE_DIR
> @dir = dir
> @lock = Lockfile.new lockfile, :retries => 0, :max_age => nil
> + @sync_worker = nil
> + @sync_queue = Queue.new
> end
>
> def lockfile; File.join @dir, "lock" end
> @@ -175,10 +177,32 @@ class BaseIndex
>
> def save_thread t
> t.each_dirty_message do |m|
> - update_message_state m
> + if @sync_worker
> + @sync_queue << m
> + else
> + update_message_state m
> + end
> m.clear_dirty
> end
> end
> +
> + def start_sync_worker
> + @sync_worker = Redwood::reporting_thread('index sync') { run_sync_worker }
> + end
> +
> + def stop_sync_worker
> + return unless worker = @sync_worker
> + @sync_worker = nil
> + @sync_queue << :die
> + worker.join
> + end
> +
> + def run_sync_worker
> + while m = @sync_queue.deq
> + return if m == :die
> + update_message_state m
> + end
> + end
> end
>
> index_name = ENV['SUP_INDEX'] || $config[:index] || DEFAULT_INDEX
> diff --git a/lib/sup/modes/thread-index-mode.rb b/lib/sup/modes/thread-index-mode.rb
> index 370903a..d2b1651 100644
> --- a/lib/sup/modes/thread-index-mode.rb
> +++ b/lib/sup/modes/thread-index-mode.rb
> @@ -477,7 +477,7 @@ EOS
> 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
> - Index.save_thread t
> + Index.save_thread_async t
> end
> end
> end
> --
> 1.6.4.2
>
> _______________________________________________
> sup-talk mailing list
> sup-talk@rubyforge.org
> http://rubyforge.org/mailman/listinfo/sup-talk
>
_______________________________________________
sup-talk mailing list
sup-talk@rubyforge.org
http://rubyforge.org/mailman/listinfo/sup-talk
next prev parent reply other threads:[~2009-11-09 6:03 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-11-05 5:45 [sup-talk] [PATCH 1/4] factor saving out of thread/message classes Rich Lane
2009-11-05 5:45 ` [sup-talk] [PATCH 2/4] async thread indexing Rich Lane
2009-11-05 5:45 ` [sup-talk] [PATCH 3/4] immediate " Rich Lane
2009-11-05 5:45 ` [sup-talk] [PATCH 4/4] force the index sync thread to give up the cpu Rich Lane
2009-11-09 6:02 ` Eugene Marinelli [this message]
2009-11-09 6:22 ` [sup-talk] [PATCH 2/4] async thread indexing Rich Lane
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=69d60e3a0911082202t31561f18mf5e24dda7a108b58@mail.gmail.com \
--to=eugeneiiim@gmail.com \
--cc=rlane@club.cc.cmu.edu \
--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