diff options
| author | Matthew Sackman <matthew@lshift.net> | 2009-08-27 16:06:39 +0100 |
|---|---|---|
| committer | Matthew Sackman <matthew@lshift.net> | 2009-08-27 16:06:39 +0100 |
| commit | c6ad55e7e6096ed2d5f2b1043b4dedc33317c432 (patch) | |
| tree | a3d7381156836489397f41e274449e1e085a076e | |
| parent | d8896bb2e4c1de2098d6fae051ccb93e6ec96926 (diff) | |
| download | rabbitmq-server-git-c6ad55e7e6096ed2d5f2b1043b4dedc33317c432.tar.gz | |
cosmetics
| -rw-r--r-- | src/rabbit_queue_prefetcher.erl | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/src/rabbit_queue_prefetcher.erl b/src/rabbit_queue_prefetcher.erl index eddb613cba..3b1c219d5a 100644 --- a/src/rabbit_queue_prefetcher.erl +++ b/src/rabbit_queue_prefetcher.erl @@ -52,6 +52,10 @@ queue_mref }). +%%---------------------------------------------------------------------------- +%% Novel +%%---------------------------------------------------------------------------- + %% The design of the prefetcher is based on the following: %% %% a) It must issue low-priority (-ve) requests to the disk queue for @@ -117,12 +121,12 @@ %% %% Now at some point, the mixed_queue will come along and will call %% prefetcher:drain() - normal priority call. The prefetcher then -%% replies with its internal queue and the length of that queue. If -%% the prefetch target was reached, the prefetcher stops normally at -%% this point. If it hasn't been reached, then the prefetcher -%% continues to hang around (it almost certainly has issued a -%% disk_queue:prefetch(Q) cast and is waiting for a reply from the -%% disk_queue). +%% replies with its internal queue and a flag saying if the prefetcher +%% has finished or is continuing; if the prefetch target was reached, +%% the prefetcher stops normally at this point. If it hasn't been +%% reached, then the prefetcher continues to hang around (it almost +%% certainly has issued a disk_queue:prefetch(Q) cast and is waiting +%% for a reply from the disk_queue). %% %% If the mixed_queue calls prefetcher:drain() and the prefetcher's %% internal queue is empty then the prefetcher replies with 'empty', @@ -174,17 +178,21 @@ %% redelivered bit set false really are guaranteed to have not been %% delivered already. +%%---------------------------------------------------------------------------- + -ifdef(use_specs). -spec(start_link/2 :: (queue_name(), non_neg_integer()) -> ({'ok', pid()} | 'ignore' | {'error', any()})). --spec(publish/2 :: (pid(), message()) -> 'ok'). +-spec(publish/2 :: (pid(), (message()| 'empty')) -> 'ok'). -spec(drain/1 :: (pid()) -> ('empty' | {queue(), ('finished' | 'continuing')})). -spec(drain_and_stop/1 :: (pid()) -> ('empty' | queue())). -spec(stop/1 :: (pid()) -> 'ok'). -endif. +%%---------------------------------------------------------------------------- + start_link(Queue, Count) -> gen_server2:start_link(?MODULE, [Queue, Count, self()], []). @@ -203,6 +211,8 @@ drain_and_stop(Prefetcher) -> stop(Prefetcher) -> gen_server2:call(Prefetcher, stop, infinity). +%%---------------------------------------------------------------------------- + init([Q, Count, QPid]) when Count > 0 andalso is_pid(QPid) -> %% link isn't enough because the signal will not appear if the %% queue exits normally. Thus have to use monitor. |
