【问题标题】:Return Msg to Caller when state_timeout occur in gen_statem erlang当 gen_statem erlang 中发生 state_timeout 时,将 Msg 返回给 Caller
【发布时间】:2020-06-16 18:47:48
【问题描述】:

例如: 状态如下所示:

state1({call,Caller},Msg,Data) ->
    NewData = do_somthing(),
    {next_State,state2,NewData,[{reply,Caller,NewMsg},{state_timeout,5000,any}]}.

超时状态:

state2(state_timeout,Msg,Data) ->
    something() ( Here my question)

我需要在超时发生时返回一条消息。 如果我不知道 state2(state_timeout,Msg,Data) 的调用者是谁,我该怎么做?

【问题讨论】:

    标签: erlang timeout message-passing gen-server reply


    【解决方案1】:

    Data 可以是任何你想要的:

    NewData = {do_something(), Caller},
    

    然后:

    state2(state_timeout,Msg,{Data, Caller}) ->
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-08-12
      • 1970-01-01
      • 2020-12-03
      • 1970-01-01
      • 1970-01-01
      • 2016-04-03
      • 2022-01-07
      • 2013-04-01
      相关资源
      最近更新 更多