Skip to content

Commit

Permalink
KAZOO-4394: latest spec/type updates
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesaimonetti authored and fenollp committed Jan 20, 2016
1 parent 4d99a3e commit 29ea5c7
Show file tree
Hide file tree
Showing 39 changed files with 82 additions and 72 deletions.
2 changes: 1 addition & 1 deletion core/whistle-1.0.0/src/wh_util.erl
Original file line number Diff line number Diff line change
Expand Up @@ -1334,7 +1334,7 @@ elapsed_us({_,_,_}=Start, Now) -> elapsed_us(now_s(Start), Now);
elapsed_us(Start, {_,_,_}=Now) -> elapsed_us(Start, now_s(Now));
elapsed_us(Start, Now) when is_integer(Start), is_integer(Now) -> (Now - Start) * 1000000.

-spec now() -> wh_now().
-spec erlang:timestamp() -> wh_now().

-ifdef(OTP_AT_LEAST_18).
now() -> erlang:timestamp().
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

init(_Transport, _Req, []) ->
% For the random number generator:
{X, Y, Z} = now(),
{X, Y, Z} = erlang:timestamp(),
random:seed(X, Y, Z),
{upgrade, protocol, cowboy_rest}.

Expand Down
2 changes: 1 addition & 1 deletion deps/erlydtl-0.9.4/src/erlydtl_filters.erl
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,7 @@ random(_) ->
"".

random_num(Value) ->
random:seed(now()),
random:seed(erlang:timestamp()),
random:uniform(Value).

%% random tags to be used when using erlydtl in testing
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ init([Args, Owner]) ->
HostStr = host_to_list(Host),
OnReplyFun = proplists:get_value(on_reply, Args, fun(_) -> ok end),
OnConnectFun = proplists:get_value(on_connect, Args, fun(_) -> ok end),
{MS, S, MMS} = now(),
{MS, S, MMS} = erlang:timestamp(),
InitRid = MS * 1000000 * 1000000 + S * 1000000 + MMS,
{ok, Parser} = exml_stream:new_parser(),
{ok, Client} = fusco_cp:start_link({HostStr, Port, HTTPS},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ terminate(_, _) ->

save_stanza(Type, Jid, Stanza, State=#state{events = Events}) ->
State#state{
events = [{stanza, Type, Jid, now(), Stanza}|Events]}.
events = [{stanza, Type, Jid, erlang:timestamp(), Stanza}|Events]}.

save_story_event(Type, State=#state{events = Events}) ->
State#state{
events = [{story, Type, now()}|Events]}.
events = [{story, Type, erlang:timestamp()}|Events]}.
2 changes: 1 addition & 1 deletion deps/exmpp-0.9.9/src/network/exmpp_bosh.erl
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ wping(_Pid) ->
%% don't do anything on init. We establish the connection when the stream start
%% is sent
init([ClientPid, StreamRef, URL, Domain, Options]) ->
{A,B,C} = now(),
{A,B,C} = erlang:timestamp(),
random:seed(A,B,C),
Rid = 1000 + random:uniform(100000),
ParsedUrl = parse_url(URL),
Expand Down
2 changes: 1 addition & 1 deletion deps/exmpp-0.9.9/src/network/exmpp_component.erl
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ set_controlling_process(Component,Client) when is_pid(Component), is_pid(Client)
init([Pid]) ->
inets:start(),
exmpp_stringprep:start(),
{A1,A2,A3} = now(),
{A1,A2,A3} = erlang:timestamp(),
random:seed(A1, A2, A3),
{ok, setup, #state{client_pid=Pid}}.

Expand Down
2 changes: 1 addition & 1 deletion deps/exmpp-0.9.9/src/network/exmpp_dns.erl
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ get_s2s(Domain) ->
%% Port = integer()

get_servers(Service, Proto, Domain, DefaultPort) ->
{S1, S2, S3} = now(),
{S1, S2, S3} = erlang:timestamp(),
random:seed(S1, S2, S3),
Name = "_" ++ Service ++ "._" ++ Proto ++ "." ++ Domain,
AddrList = case do_query(Name, Domain, DefaultPort) of
Expand Down
4 changes: 2 additions & 2 deletions deps/exmpp-0.9.9/src/network/exmpp_session.erl
Original file line number Diff line number Diff line change
Expand Up @@ -409,15 +409,15 @@ init([Pid]) ->
inets:start(),
exmpp_stringprep:start(),

{A1,A2,A3} = now(),
{A1,A2,A3} = erlang:timestamp(),
random:seed(A1, A2, A3),
{ok, setup, #state{client_pid=Pid, stream_version = {0,0}}}; %%if not specified, do not use version 1.0
init([Pid, Version]) ->
inets:start(),
exmpp_stringprep:start(),
exmpp_compress:start(),

{A1,A2,A3} = now(),
{A1,A2,A3} = erlang:timestamp(),
random:seed(A1, A2, A3),
{ok, setup, #state{client_pid=Pid, stream_version = Version}}.

Expand Down
4 changes: 2 additions & 2 deletions deps/ibrowse-4.0.1/src/ibrowse_http_client.erl
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ accumulate_response(Data, #state{reply_buffer = RepBuf,

make_tmp_filename(true) ->
DownloadDir = ibrowse:get_config_value(download_dir, filename:absname("./")),
{A,B,C} = now(),
{A,B,C} = erlang:timestamp(),
filename:join([DownloadDir,
"ibrowse_tmp_file_"++
integer_to_list(A) ++
Expand Down Expand Up @@ -1805,7 +1805,7 @@ cancel_timer(Ref, {eat_message, Msg}) ->
end.

make_req_id() ->
now().
erlang:timestamp().

to_lower(Str) ->
to_lower(Str, []).
Expand Down
2 changes: 1 addition & 1 deletion deps/ibrowse-4.0.1/src/ibrowse_lib.erl
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ default_port(ftp) -> 21.

printable_date() ->
{{Y,Mo,D},{H, M, S}} = calendar:local_time(),
{_,_,MicroSecs} = now(),
{_,_,MicroSecs} = erlang:timestamp(),
[integer_to_list(Y),
$-,
integer_to_list(Mo),
Expand Down
8 changes: 4 additions & 4 deletions deps/ibrowse-4.0.1/src/ibrowse_test.erl
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ load_test(Url, NumWorkers, NumReqsPerWorker) when is_list(Url),
proc_lib:spawn(?MODULE, send_reqs_1, [Url, NumWorkers, NumReqsPerWorker]).

send_reqs_1(Url, NumWorkers, NumReqsPerWorker) ->
Start_time = now(),
Start_time = erlang:timestamp(),
ets:new(pid_table, [named_table, public]),
ets:new(ibrowse_test_results, [named_table, public]),
ets:new(ibrowse_errors, [named_table, public, ordered_set]),
Expand All @@ -89,7 +89,7 @@ send_reqs_1(Url, NumWorkers, NumReqsPerWorker) ->
spawn_workers(Url, NumWorkers, NumReqsPerWorker),
log_msg("Finished spawning workers...~n", []),
do_wait(Url),
End_time = now(),
End_time = erlang:timestamp(),
log_msg("All workers are done...~n", []),
log_msg("ibrowse_test_results table: ~n~p~n", [ets:tab2list(ibrowse_test_results)]),
log_msg("Start time: ~1000.p~n", [calendar:now_to_local_time(Start_time)]),
Expand Down Expand Up @@ -167,7 +167,7 @@ do_send_req_1(Url, NumReqs) ->
{error, retry_later} ->
ets:update_counter(ibrowse_test_results, retry_later, 1);
Err ->
ets:insert(ibrowse_errors, {now(), Err}),
ets:insert(ibrowse_errors, {erlang:timestamp(), Err}),
ets:update_counter(ibrowse_test_results, other_error, 1),
ok
end,
Expand All @@ -178,7 +178,7 @@ dump_errors() ->
0 ->
ok;
_ ->
{A, B, C} = now(),
{A, B, C} = erlang:timestamp(),
Filename = lists:flatten(
io_lib:format("ibrowse_errors_~p_~p_~p.txt" , [A, B, C])),
case file:open(Filename, [write, delayed_write, raw]) of
Expand Down
4 changes: 2 additions & 2 deletions deps/mochiweb-2.4.2/src/mochiweb_acceptor.erl
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ start_link(Server, Listen, Loop) ->
proc_lib:spawn_link(?MODULE, init, [Server, Listen, Loop]).

init(Server, Listen, Loop) ->
T1 = now(),
T1 = erlang:timestamp(),
case catch mochiweb_socket:accept(Listen) of
{ok, Socket} ->
gen_server:cast(Server, {accepted, self(), timer:now_diff(now(), T1)}),
gen_server:cast(Server, {accepted, self(), timer:now_diff(erlang:timestamp(), T1)}),
call_loop(Loop, Socket);
{error, closed} ->
exit(normal);
Expand Down
2 changes: 1 addition & 1 deletion deps/nksip-0.4.0/include/nksip.hrl
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@
-define(TIMEOFF(Var),
io:format("~s :: ~10.2f ms : ~p~n", [
string:copies(" ", length(erlang:get(debug_timer))),
(timer:now_diff(now(), hd(erlang:get(debug_timer)))/1000), Var
(timer:now_diff(erlang:timestamp(), hd(erlang:get(debug_timer)))/1000), Var
]),
erlang:put(debug_timer, tl(erlang:get(debug_timer)))).
-endif.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,10 +204,10 @@ launch(Opts) ->
end
end,
empty(),
Start = now(),
Start = erlang:timestamp(),
[proc_lib:spawn(fun() -> Fun(Pos) end) || Pos <- lists:seq(1, Processes)],
Ok = wait(Total, 0),
Stop = now();
Stop = erlang:timestamp();
full ->
case NoAutoStart of
true -> ok;
Expand All @@ -220,10 +220,10 @@ launch(Opts) ->
end,
timer:sleep(100),
empty(),
Start = now(),
Start = erlang:timestamp(),
[proc_lib:spawn(fun() -> Fun(Pos) end) || Pos <- lists:seq(1, Processes)],
Ok = wait(Total, 0),
Stop = now(),
Stop = erlang:timestamp(),
case NoAutoStart of
true -> ok;
false -> ok = stop_clients(Processes)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -863,7 +863,7 @@ large_content_test() ->
{ok, Channel} = amqp_connection:open_channel(Connection),
#'queue.declare_ok'{queue = Q}
= amqp_channel:call(Channel, #'queue.declare'{}),
{A1,A2,A3} = now(), random:seed(A1, A2, A3),
{A1,A2,A3} = erlang:timestamp(), random:seed(A1, A2, A3),
F = list_to_binary([random:uniform(256)-1 || _ <- lists:seq(1, 1000)]),
Payload = list_to_binary([[F || _ <- lists:seq(1, 1000)]]),
Publish = #'basic.publish'{exchange = <<>>, routing_key = Q},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ remove_credentials(URI) ->
list_to_binary(amqp_uri:remove_credentials(binary_to_list(URI))).

to_params(Upstream = #upstream{uris = URIs}, XorQ) ->
random:seed(now()),
random:seed(erlang:timestamp()),
URI = lists:nth(random:uniform(length(URIs)), URIs),
{ok, Params} = amqp_uri:parse(binary_to_list(URI), vhost(XorQ)),
XorQ1 = with_name(Upstream, vhost(Params), XorQ),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ handle_call(_Msg, _From, State) ->
{noreply, State}.

handle_cast(init, State = #state{config = Config}) ->
random:seed(now()),
random:seed(erlang:timestamp()),
#shovel{sources = Sources, destinations = Destinations} = Config,
{InboundConn, InboundChan, InboundURI} =
make_conn_and_chan(Sources#endpoint.uris),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
cache_for(Req, Headers) ->
Expires = calendar:gregorian_seconds_to_datetime(
calendar:datetime_to_gregorian_seconds(
calendar:now_to_datetime(now())) + ?YEAR),
calendar:now_to_datetime(erlang:timestamp())) + ?YEAR),
H = [{"Cache-Control", "public, max-age=" ++ integer_to_list(?YEAR)},
{"Expires", httpd_util:rfc1123_date(Expires)}],
{H ++ Headers, Req}.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
rand32() ->
case get(random_seeded) of
undefined ->
{MegaSecs, Secs, MicroSecs} = now(),
{MegaSecs, Secs, MicroSecs} = erlang:timestamp(),
_ = random:seed(MegaSecs, Secs, MicroSecs),
put(random_seeded, true);
_Else ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ new_request(mochiweb, Request) ->
{Peer, ReqState} = InitReq:get_peer(),
PeerState = ReqState#wm_reqstate{reqdata=wrq:set_peer(Peer,
ReqState#wm_reqstate.reqdata)},
LogData = #wm_log_data{start_time=now(),
LogData = #wm_log_data{start_time=erlang:timestamp(),
method=Method,
headers=Headers,
peer=PeerState#wm_reqstate.peer,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ respond(Code) when is_integer(Code) ->
respond({Code, undefined});
respond({_, _}=CodeAndPhrase) ->
Resource = get(resource),
EndTime = now(),
EndTime = erlang:timestamp(),
respond(CodeAndPhrase, Resource, EndTime).

respond({Code, _ReasonPhrase}=CodeAndPhrase, Resource, EndTime)
Expand Down Expand Up @@ -104,7 +104,7 @@ error_response(Reason) ->

error_response(Code, Reason) ->
Resource = get(resource),
EndTime = now(),
EndTime = erlang:timestamp(),
error_response({Code, undefined}, Reason, Resource, EndTime).

error_response({Code, _}=CodeAndPhrase, Resource, EndTime) ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ call({send_response, {Code, ReasonPhrase}=CodeAndReason}, Req) when is_integer(C
send_response(CodeAndReason, Req)
end,
LogData = NewState#wm_reqstate.log_data,
NewLogData = LogData#wm_log_data{finish_time=now()},
NewLogData = LogData#wm_log_data{finish_time=erlang:timestamp()},
{Reply, NewState#wm_reqstate{log_data=NewLogData}};
call(resp_body, {?MODULE, ReqState}) ->
{wrq:resp_body(ReqState#wm_reqstate.reqdata), ReqState};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ log_decision(File, DecisionID) ->
io:format(File, "{decision, ~p}.~n", [DecisionID]).

open_log_file(Dir, Mod) ->
Now = {_,_,US} = now(),
Now = {_,_,US} = erlang:timestamp(),
{{Y,M,D},{H,I,S}} = calendar:now_to_universal_time(Now),
Filename = io_lib:format(
"~s/~p-~4..0B-~2..0B-~2..0B"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -368,14 +368,14 @@ unescape_quoted_string([Char | Rest], Acc) ->
unescape_quoted_string(Rest, [Char | Acc]).


%% @type now() = {MegaSecs, Secs, MicroSecs}
%% @type erlang:timestamp() = {MegaSecs, Secs, MicroSecs}

%% This is faster than timer:now_diff() because it does not use bignums.
%% But it returns *milliseconds* (timer:now_diff returns microseconds.)
%% From http://www.erlang.org/ml-archive/erlang-questions/200205/msg00027.html

%% @doc Compute the difference between two now() tuples, in milliseconds.
%% @spec now_diff_milliseconds(now(), now()) -> integer()
%% @doc Compute the difference between two erlang:timestamp() tuples, in milliseconds.
%% @spec now_diff_milliseconds(erlang:timestamp(), erlang:timestamp()) -> integer()
now_diff_milliseconds(undefined, undefined) ->
0;
now_diff_milliseconds(undefined, T2) ->
Expand Down
10 changes: 5 additions & 5 deletions deps/rabbitmq_server-3.5.5/src/file_handle_cache.erl
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,7 @@ clear(Ref) ->
end).

set_maximum_since_use(MaximumAge) ->
Now = now(),
Now = erlang:timestamp(),
case lists:foldl(
fun ({{Ref, fhc_handle},
Handle = #handle { hdl = Hdl, last_used_at = Then }}, Rep) ->
Expand Down Expand Up @@ -708,7 +708,7 @@ get_or_reopen(RefNewOrReopens) ->
{OpenHdls, []} ->
{ok, [Handle || {_Ref, Handle} <- OpenHdls]};
{OpenHdls, ClosedHdls} ->
Oldest = oldest(get_age_tree(), fun () -> now() end),
Oldest = oldest(get_age_tree(), fun () -> erlang:timestamp() end),
case gen_server2:call(?SERVER, {open, self(), length(ClosedHdls),
Oldest}, infinity) of
ok ->
Expand Down Expand Up @@ -744,7 +744,7 @@ reopen([{Ref, NewOrReopen, Handle = #handle { hdl = closed,
end,
case prim_file:open(Path, Mode) of
{ok, Hdl} ->
Now = now(),
Now = erlang:timestamp(),
{{ok, _Offset}, Handle1} =
maybe_seek(Offset, reset_read_buffer(
Handle#handle{hdl = Hdl,
Expand Down Expand Up @@ -780,7 +780,7 @@ sort_handles([{Ref, _} | RefHdls], RefHdlsA, [{Ref, Handle} | RefHdlsB], Acc) ->
sort_handles(RefHdls, RefHdlsA, RefHdlsB, [Handle | Acc]).

put_handle(Ref, Handle = #handle { last_used_at = Then }) ->
Now = now(),
Now = erlang:timestamp(),
age_tree_update(Then, Now, Ref),
put({Ref, fhc_handle}, Handle #handle { last_used_at = Now }).

Expand Down Expand Up @@ -1419,7 +1419,7 @@ reduce(State = #fhc_state { open_pending = OpenPending,
elders = Elders,
clients = Clients,
timer_ref = TRef }) ->
Now = now(),
Now = erlang:timestamp(),
{CStates, Sum, ClientCount} =
ets:foldl(fun ({Pid, Eldest}, {CStatesAcc, SumAcc, CountAcc} = Accs) ->
[#cstate { pending_closes = PendingCloses,
Expand Down
6 changes: 3 additions & 3 deletions deps/rabbitmq_server-3.5.5/src/gen_server2.erl
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,7 @@ unregister_name(_Name) -> ok.
extend_backoff(undefined) ->
undefined;
extend_backoff({backoff, InitialTimeout, MinimumTimeout, DesiredHibPeriod}) ->
{backoff, InitialTimeout, MinimumTimeout, DesiredHibPeriod, now()}.
{backoff, InitialTimeout, MinimumTimeout, DesiredHibPeriod, erlang:timestamp()}.

%%%========================================================================
%%% Internal functions
Expand Down Expand Up @@ -695,15 +695,15 @@ wake_hib(GS2State = #gs2_state { timeout_state = TS }) ->
undefined ->
undefined;
{SleptAt, TimeoutState} ->
adjust_timeout_state(SleptAt, now(), TimeoutState)
adjust_timeout_state(SleptAt, erlang:timestamp(), TimeoutState)
end,
post_hibernate(
drain(GS2State #gs2_state { timeout_state = TimeoutState1 })).

hibernate(GS2State = #gs2_state { timeout_state = TimeoutState }) ->
TS = case TimeoutState of
undefined -> undefined;
{backoff, _, _, _, _} -> {now(), TimeoutState}
{backoff, _, _, _, _} -> {erlang:timestamp(), TimeoutState}
end,
proc_lib:hibernate(?MODULE, wake_hib,
[GS2State #gs2_state { timeout_state = TS }]).
Expand Down
2 changes: 1 addition & 1 deletion deps/rabbitmq_server-3.5.5/src/gm.erl
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,7 @@ forget_group(GroupName) ->

init([GroupName, Module, Args, TxnFun]) ->
put(process_name, {?MODULE, GroupName}),
{MegaSecs, Secs, MicroSecs} = now(),
{MegaSecs, Secs, MicroSecs} = erlang:timestamp(),
random:seed(MegaSecs, Secs, MicroSecs),
Self = make_member(GroupName),
gen_server2:cast(self(), join),
Expand Down
Loading

0 comments on commit 29ea5c7

Please sign in to comment.