couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rnew...@apache.org
Subject git commit: new IOQ api
Date Mon, 01 Sep 2014 18:23:19 GMT
Repository: couchdb-ioq
Updated Branches:
  refs/heads/master 6293a8b88 -> 04aea7320


new IOQ api


Project: http://git-wip-us.apache.org/repos/asf/couchdb-ioq/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-ioq/commit/04aea732
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-ioq/tree/04aea732
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-ioq/diff/04aea732

Branch: refs/heads/master
Commit: 04aea732058c5f0b7081b1fa444dbf4b3761cd02
Parents: 6293a8b
Author: Robert Newson <rnewson@apache.org>
Authored: Mon Sep 1 19:20:09 2014 +0100
Committer: Robert Newson <rnewson@apache.org>
Committed: Mon Sep 1 19:20:09 2014 +0100

----------------------------------------------------------------------
 src/ioq.erl | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-ioq/blob/04aea732/src/ioq.erl
----------------------------------------------------------------------
diff --git a/src/ioq.erl b/src/ioq.erl
index 686a696..4983b73 100644
--- a/src/ioq.erl
+++ b/src/ioq.erl
@@ -13,7 +13,7 @@
 -module(ioq).
 -behaviour(gen_server).
 
--export([start_link/0, call/2]).
+-export([start_link/0, call/3]).
 -export([init/1, handle_call/3, handle_cast/2, handle_info/2, code_change/3, terminate/2]).
 
 -record(state, {
@@ -27,7 +27,7 @@
 -record(request, {
     fd,
     msg,
-    class,
+    priority,
     from,
     ref
 }).
@@ -35,8 +35,8 @@
 start_link() ->
     gen_server:start_link({local, ?MODULE}, ?MODULE, [], []).
 
-call(Fd, Msg) ->
-    Request = #request{fd=Fd, msg=Msg, class=get(io_class), from=self()},
+call(Fd, Msg, Priority) ->
+    Request = #request{fd=Fd, msg=Msg, priority=Priority, from=self()},
     gen_server:call(?MODULE, Request, infinity).
 
 init(_) ->
@@ -77,7 +77,9 @@ code_change(_Vsn, State, _Extra) ->
 terminate(_Reason, _State) ->
     ok.
 
-enqueue_request(#request{class=compaction}=Request, #state{}=State) ->
+enqueue_request(#request{priority={db_compact, _}}=Request, #state{}=State) ->
+    State#state{compaction=queue:in(Request, State#state.compaction)};
+enqueue_request(#request{priority={view_compact, _, _}}=Request, #state{}=State) ->
     State#state{compaction=queue:in(Request, State#state.compaction)};
 enqueue_request(#request{}=Request, #state{}=State) ->
     State#state{interactive=queue:in(Request, State#state.interactive)}.


Mime
View raw message