我试图将消息发送给一个gen_server:
gen_server:cast({global, ID}, {watchers}).
处理程序是:
handle_cast({watchers}, State) ->
case State#table_state.watchers of
[] ->
{reply, no_watchers, State};
_ ->
{reply, State#table_state.watchers, State}
end;
但是当我执行
gen_server:cast
时,gen_server会因为错误而终止:=ERROR REPORT==== 29-Apr-2011::18:26:07 ===
** Generic server 1 terminating
** Last message in was {'$gen_cast',{watchers}}
** When Server state == {table_state,1,"1",11,[]}
** Reason for termination ==
** {bad_return_value,{reply, no_watchers, {table_state,3,"3",11,[]}}}
为什么我会收到“bad_return_value”?
{watchers}
这个元组内的原子,只需单独发送watchers
原子作为消息即可。 - Adam Lindberg