anchor.diff:                req, resp,
                 timing}).
   
  --record(bertrpc, {current = undefined :: #cmd{} | 'undefined',
  +-record(bertrpc, {current = queue:new() :: queue:queue(#cmd{}) | 'undefined',
                     commands = [] :: list()}).
   
   %%====================================================================
  
positive.code: init() ->
      #bertrpc{}.
  
  update({{Type, M, F, A}, _, _} = Req, FSM = #bertrpc{current=undefined})
    when Type =:= call; Type =:= cast ->
      FSM#bertrpc{current=#cmd{type=Type, req=Req,
                               mfa={M,F,length(A)}}};
  update({{noreply},_,_} = Resp,
         FSM = #bertrpc{current = Cmd = #cmd{type=cast}}) ->
      complete_op(Cmd#cmd{resp=Resp}, FSM);
  update({{reply, _},_,_} = Resp,
         FSM = #bertrpc{current = Cmd = #cmd{type=call}}) ->
      complete_op(Cmd#cmd{resp=Resp}, FSM);
  update({_, _, _}, FSM = #bertrpc{current=undefined}) ->
      %% XXX actually an error.
      FSM.
  
  
  complete_op(Cmd, FSM = #bertrpc{commands=Cmds}) ->
      FSM#bertrpc{commands=[Cmd | Cmds], current=undefined}.
  
  -type timestamp() :: non_neg_integer().
  -type duration() :: integer().
  
negative.code: %%%-------------------------------------------------------------------
  -module(enet_bertrpc_fsm).
  
  %% -compile(native).
  
  %% API
  -export([init/0
  