不启动timer的话, 使用infinity确实可以省一个timer
参考erlang源码
beam_emu.c1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29if (timeout_value != make_small(0)) {
if (timeout_value == am_infinity)
c_p->flags |= F_TIMO;
else {
int tres = erts_set_proc_timer_term(c_p, timeout_value);
if (tres == 0) {
/*
* The timer routiner will set c_p->i to the value in
* c_p->def_arg_reg[0]. Note that it is safe to use this
* location because there are no living x registers in
* a receive statement.
* Note that for the halfword emulator, the two first elements
* of the array are used.
*/
BeamInstr** pi = (BeamInstr**) c_p->def_arg_reg;
*pi = I+3;
}
else { /* Wrong time */
OpCase(i_wait_error_locked): {
erts_smp_proc_unlock(c_p, ERTS_PROC_LOCKS_MSG_RECEIVE);
/* Fall through */
}
OpCase(i_wait_error): {
c_p->freason = EXC_TIMEOUT_VALUE;
goto find_func_info;
}
}
}