You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by rn...@apache.org on 2019/01/30 13:20:08 UTC
[couchdb-ioq] 02/17: new IOQ api
This is an automated email from the ASF dual-hosted git repository.
rnewson pushed a commit to branch cloudant-ioq
in repository https://gitbox.apache.org/repos/asf/couchdb-ioq.git
commit 04aea732058c5f0b7081b1fa444dbf4b3761cd02
Author: Robert Newson <rn...@apache.org>
AuthorDate: Mon Sep 1 19:20:09 2014 +0100
new IOQ api
---
src/ioq.erl | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
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)}.