Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files
Merge pull request #2 from cloudant/fix-compilation-warnings
Avoid using `erlang:now/0`
  • Loading branch information
iilyak committed Feb 25, 2019
2 parents d85183d + 55bf6a3 commit 8553ee662c6bfd08daabf521cf5c46e0e1696b9b
Showing 2 changed files with 11 additions and 6 deletions.
@@ -24,8 +24,8 @@ new() ->

last_updated(Key, #priority_queue{dict=Dict}) ->
case dict:find(Key, Dict) of
{ok, {_, LastUpdated}} ->
LastUpdated;
{ok, {_Priority, {LastUpdatedMTime, _MInt}}} ->
LastUpdatedMTime;
error ->
false
end.
@@ -43,7 +43,8 @@ in(Key, Value, Priority, Capacity, #priority_queue{dict=Dict, tree=Tree}) ->
error ->
Tree
end,
TreeKey1 = {Priority, now()},
Now = {erlang:monotonic_time(), erlang:unique_integer([monotonic])},
TreeKey1 = {Priority, Now},
Tree2 = gb_trees:enter(TreeKey1, {Key, Value}, Tree1),
Dict1 = dict:store(Key, TreeKey1, Dict),
truncate(Capacity, #priority_queue{dict=Dict1, tree=Tree2}).
@@ -28,6 +28,8 @@
status/0
]).

-define(SECONDS_PER_MINUTE, 60).

% gen_server api.
-export([init/1, handle_call/3, handle_cast/2, handle_info/2,
code_change/3, terminate/2]).
@@ -264,9 +266,11 @@ find_channel(_Tab, [], _Object) ->
find_channel(Tab, [Channel|Rest], Object) ->
Pid = channel_pid(Tab, Channel),
LastUpdated = smoosh_channel:last_updated(Pid, Object),
Staleness = 6.0e7 * list_to_integer(config:get("smoosh", "staleness", "5")),
case LastUpdated =:= false orelse
timer:now_diff(now(), LastUpdated) > Staleness of
StalenessInSec = config:get_integer("smoosh", "staleness", 5)
* ?SECONDS_PER_MINUTE,
Staleness = erlang:convert_time_unit(StalenessInSec, seconds, native),
Now = erlang:monotonic_time(),
case LastUpdated =:= false orelse Now - LastUpdated > Staleness of
true ->
case smoosh_utils:ignore_db(Object) of
true ->

0 comments on commit 8553ee6

Please sign in to comment.