[erlang-questions] About erlang:statistics/1 and timeout values
Thu Apr 23 13:31:08 CEST 2009
I was looking at statistics in the erlang module and found that
statistics(runtime) and statistics(wall_clock) returns something called
Time_Sinse_Last_Call. I assume that this is "since last call by the
calling process" and not a globally kept value. It also seems like this
is the case due to the following output:
23> spawn(fun() -> statistics(wall_clock) end), statistics(wall_clock).
Should this be pointed out in the manual?
Essentially, what I want to achieve is to have a timeout value which I
can easily recalculate between calls to several blocking functions so
that the total timeout never is more than the specified. So, for
instance I'd have a timeout value that I decrease with the
element(2,statistics(wall_clock)), each time I need to pass it to a
function such as gen_tcp:recv/3.
Would there be a better way of doing this than using
statistics(wall_clock)? I've looked at the erlang:start_timer/3, but it
send a message, which isn't very useful if the process is stuck in a
blocking call. It however allows me to use erlang:read_timer/1, which
would give me the timeout value without having to calculate it from
total elapsed time between calls...
Office: +44 20 7655 0337
Mobile: +44 798 45 44 773
Erlang Training and Consulting Ltd
More information about the erlang-questions