You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@couchdb.apache.org by GitBox <gi...@apache.org> on 2018/12/23 05:00:51 UTC

[GitHub] jaydoane closed pull request #7: Suppress erlang:now/0 deprecation warnings

jaydoane closed pull request #7: Suppress erlang:now/0 deprecation warnings
URL: https://github.com/apache/couchdb-ets-lru/pull/7
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/.travis.yml b/.travis.yml
index 99e6cb3..cfee153 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,10 +1,13 @@
 language: erlang
+os: linux
+dist: trusty
 
 otp_release:
+   - 21.2
+   - 20.3
+   - 19.3
+   - 18.3
    - 17.5
-   - 17.4
-   - 17.1
-   - 17.0
-   - R16B03-1
-   - R14B04
-   - R14B02
+
+script:
+  - rebar eunit
diff --git a/rebar.config b/rebar.config
new file mode 100644
index 0000000..2be0158
--- /dev/null
+++ b/rebar.config
@@ -0,0 +1,7 @@
+{erl_opts, [
+    {platform_define, "^17", 'NO_EXTENDED_TIME_FUNC'}
+]}.
+
+{eunit_compile_opts, [
+    {platform_define, "^17", 'NO_EXTENDED_TIME_FUNC'}
+]}.
diff --git a/src/ets_lru.erl b/src/ets_lru.erl
index 7a366ba..b28117d 100644
--- a/src/ets_lru.erl
+++ b/src/ets_lru.erl
@@ -164,7 +164,7 @@ handle_call({match, KeySpec, ValueSpec}, _From, St) ->
     {reply, Values, St, 0};
 
 handle_call({insert, Key, Val}, _From, St) ->
-    NewATime = erlang:now(),
+    NewATime = unique_now(),
     Pattern = #entry{key=Key, atime='$1', _='_'},
     case ets:match(St#st.objects, Pattern) of
         [[ATime]] ->
@@ -233,7 +233,7 @@ accessed(Key, St) ->
     Pattern = #entry{key=Key, atime='$1', _='_'},
     case ets:match(St#st.objects, Pattern) of
         [[ATime]] ->
-            NewATime = erlang:now(),
+            NewATime = unique_now(),
             Update = {#entry.atime, NewATime},
             true = ets:update_element(St#st.objects, Key, Update),
             true = ets:delete(St#st.atimes, ATime),
@@ -350,3 +350,20 @@ ct_table(Name) ->
 
 table_name(Name, Ext) ->
     list_to_atom(atom_to_list(Name) ++ Ext).
+
+
+-ifdef(NO_EXTENDED_TIME_FUNC).
+
+
+unique_now() ->
+    erlang:now().
+
+
+-else.
+
+
+unique_now() ->
+    erlang:timestamp().
+
+
+-endif.
diff --git a/test/ets_lru_test.erl b/test/ets_lru_test.erl
index 21d8e28..0f1cc4a 100644
--- a/test/ets_lru_test.erl
+++ b/test/ets_lru_test.erl
@@ -1,6 +1,5 @@
 -module(ets_lru_test).
 
--compile([export_all]).
 
 -include_lib("eunit/include/eunit.hrl").
 


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services