couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rnew...@apache.org
Subject [18/24] couch commit: updated refs/heads/windsor-merge-122 to 2f3a1fd
Date Tue, 05 Aug 2014 15:02:30 GMT
Improve code_change and #proc{} imports

Going forward we should define default values for all fields of a
proc_int that are not shared by a proc.  This allows us to implement the
general import_proc/1 function that I've added (and used in code_change)
here.

BugzID: 19529


Project: http://git-wip-us.apache.org/repos/asf/couchdb-couch/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-couch/commit/08a25ad7
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-couch/tree/08a25ad7
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-couch/diff/08a25ad7

Branch: refs/heads/windsor-merge-122
Commit: 08a25ad7d43c83169120ccce64256a5028718490
Parents: acb80ab
Author: Adam Kocoloski <adam@cloudant.com>
Authored: Tue Jun 4 16:36:22 2013 -0400
Committer: Robert Newson <rnewson@apache.org>
Committed: Tue Aug 5 12:03:15 2014 +0100

----------------------------------------------------------------------
 src/couch_proc_manager.erl | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-couch/blob/08a25ad7/src/couch_proc_manager.erl
----------------------------------------------------------------------
diff --git a/src/couch_proc_manager.erl b/src/couch_proc_manager.erl
index 8cb53cb..f84c06a 100644
--- a/src/couch_proc_manager.erl
+++ b/src/couch_proc_manager.erl
@@ -233,12 +233,7 @@ terminate(_Reason, #state{tab=Tab}) ->
 
 code_change(_OldVsn, {state, Tab}, _Extra) ->
     State = #state{tab = Tab, threshold_ts = {0,0,0}},
-    ProcInts = lists:map(
-        fun(#proc{} = P) ->
-            setelement(1, erlang:append_element(P, os:timestamp()), proc_int)
-        end,
-        ets:tab2list(Tab)
-    ),
+    ProcInts = lists:map(fun import_proc/1, ets:tab2list(Tab)),
     ets:delete_all_objects(Tab),
     ets:insert(Tab, ProcInts),
     {ok, State}.
@@ -433,6 +428,11 @@ export_proc(#proc_int{} = ProcInt) ->
     [_ | Data] = lists:sublist(record_info(size, proc), tuple_to_list(ProcInt)),
     list_to_tuple([proc | Data]).
 
+import_proc(#proc{} = P) ->
+    lists:foldl(fun(Idx, ProcInt) ->
+        setelement(Idx, ProcInt, element(Idx, P))
+    end, #proc_int{}, lists:seq(2, tuple_size(P))).
+
 maybe_spawn_proc(State, Client) ->
     #state{proc_counts=Counts, waiting=Waiting} = State,
     #client{lang=Lang} = Client,


Mime
View raw message