Skip to content

Commit

Permalink
hibari >> GH51 - Update for Erlang/OTP 18
Browse files Browse the repository at this point in the history
- Add "18" to require_otp_vsn of rebar.config
- Replace deprecated erlang:now/0 with gmt_time_otp18 functions
  such as monotonic_time/0, timestamp/0 and erlang_system_time/1.
- Replace make_now/1's implemantation to have less number of rem
  operations.
  • Loading branch information
tatsuya6502 committed Nov 10, 2015
1 parent 8c7fb13 commit aa0839e
Show file tree
Hide file tree
Showing 6 changed files with 87 additions and 75 deletions.
3 changes: 1 addition & 2 deletions rebar.config
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
%%% -*- mode: erlang -*-

%% Require OTP version R16 or 17
{require_otp_vsn, "R16|17"}.
{require_otp_vsn, "R16|17|18"}.

%% Depends
{deps_dir, "../"}.
Expand Down
13 changes: 9 additions & 4 deletions src/brick_ets.erl
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@

-include_lib("kernel/include/file.hrl").

-define(TIME, gmt_time_otp18).

-define(CHECK_NAME, "CHECK").
-define(CHECK_FILE, ?CHECK_NAME ++ ".LOG").

Expand Down Expand Up @@ -348,7 +350,8 @@ init([ServerName, Options]) ->
%% log's directory name: hlog.X
%% log's registered name: X_hlog
LogDir = WalMod:log_name2data_dir(ServerName),
State0 = #state{name = ServerName, options = Options, start_time = now(),
State0 = #state{name = ServerName, options = Options,
start_time = ?TIME:timestamp(),
do_logging = DoLogging, do_sync = DoSync,
log_dir = LogDir, bigdata_dir = BigDataDir,
log = LogPid, ctab = CTab, etab = ETab, mdtab = MDTab,
Expand Down Expand Up @@ -2341,10 +2344,11 @@ sync_pid_loop(SPA) ->
LastSerial = sync_get_last_serial(L),
?DBG_GEN("SPA ~w requesting sync last serial = ~w",
[SPA#syncpid_arg.name, LastSerial]),
Start = now(), %qqq debug
Start = ?TIME:monotonic_time(),
{ok, _X, _Y} = wal_sync(SPA#syncpid_arg.wal_pid,
SPA#syncpid_arg.wal_mod),
DiffMS = timer:now_diff(now(), Start) div 1000, %qqq debug
End = ?TIME:monotonic_time(),
DiffMS = ?TIME:convert_time_unit(End - Start, native, milli_seconds),
SPA#syncpid_arg.parent_pid !
{syncpid_stats, SPA#syncpid_arg.name, DiffMS, ms, length(L)},
?DBG_GEN("SPA ~p sync_done at ~w, ~w, my last serial = ~w",
Expand Down Expand Up @@ -3300,7 +3304,8 @@ squidflash_doit(KsRaws, DoOp, From, ParentPid, FakeS) ->
%% least? The alternative is to have a handle_call() ->
%% handle_cast() conversion doodad ... this is lazier.
{do, _SentAt, Dos, DoFlags} = DoOp,
ParentPid ! {'$gen_call', From, {do, now(), Dos, [squidflash_resubmit|DoFlags]}},
Now = ?TIME:timestamp(),
ParentPid ! {'$gen_call', From, {do, Now, Dos, [squidflash_resubmit|DoFlags]}},
exit(normal).

squidflash_prime1(Key, RawVal, ValLen, ReplyPid, FakeS) ->
Expand Down

0 comments on commit aa0839e

Please sign in to comment.