我尝试将相应的线程与时间戳(从现在开始的微秒函数(相匹配,就像吉尔收到来自约翰 [739000] 的介绍消息,约翰收到吉尔的回复消息 [739000]
if
I == true ->
M_pid!{lists:concat([Self_name," received intro message from ", Process_name , "[",erlang:now(),"]"]), self()},
%io:fwrite(I),
whereis(Process_name)!{Self_name, "reply",self()},
friends(Msg, M_pid, State + 1, Self_name);
R == true ->
M_pid!{lists:concat([Self_name," received reply message from ", Process_name , "[",pid_to_list(Process_id),"]"]), self()},
friends(Msg, M_pid, State + 1, Self_name)
end
我试图从now()
从process_id
更改为微秒。 我是 Erlang 的新手。提前谢谢你们!
erlang:now()
已被弃用,不应使用。有两个选项可以获取当前时间(以微秒为单位(
os:timestamp()
{Mega, Sec, Micro} = os:timestamp(),
(Mega * 1000000 + Sec) * 1000000 + Micro.
os:system_time(microseconds)