|
|
@ -354,6 +354,121 @@ call4(N, A1, A2, A, Fun, _key) -> |
|
|
|
erlang:apply(A, Fun, Args), |
|
|
|
call4(N - 1, A1, A2, A, Fun, Key). |
|
|
|
|
|
|
|
-define(AcList, [{eTimeout, 11, 22}, {u_eTimeout, 22}, {sTimeout, 111, 222, 333}, c_eTimeout, c_sTimeout, {nextEvent, 222, fdfd}, {doAfter, args}]). |
|
|
|
|
|
|
|
ht11(0, _Fun) -> |
|
|
|
ok; |
|
|
|
ht11(N, Fun) -> |
|
|
|
?MODULE:Fun(?AcList, 1, ttt, [], true, fasle, false, [], []), |
|
|
|
ht11(N - 1, Fun). |
|
|
|
|
|
|
|
%% 下面两中写法 并无差别 |
|
|
|
doPAL([], _CallbackForm, CycleData, Debug, IsPostpone, IsHibernate, DoAfter, Timeouts, NextEvents) -> |
|
|
|
{CycleData, Debug, IsPostpone, IsHibernate, DoAfter, Timeouts, NextEvents}; |
|
|
|
doPAL([OneAction | LeftActions], CallbackForm, CycleData, Debug, IsPostpone, IsHibernate, DoAfter, Timeouts, NextEvents) -> |
|
|
|
case OneAction of |
|
|
|
{reply, From, Reply} -> |
|
|
|
doPAL(LeftActions, CallbackForm, CycleData, Debug, IsPostpone, IsHibernate, DoAfter, Timeouts, NextEvents); |
|
|
|
{eTimeout, _Time, _TimeoutMsg} -> |
|
|
|
doPAL(LeftActions, CallbackForm, CycleData, Debug, IsPostpone, IsHibernate, DoAfter, [OneAction | Timeouts], NextEvents); |
|
|
|
{sTimeout, _Time, _TimeoutMsg} -> |
|
|
|
doPAL(LeftActions, CallbackForm, CycleData, Debug, IsPostpone, IsHibernate, DoAfter, [OneAction | Timeouts], NextEvents); |
|
|
|
{{gTimeout, _Name}, _Time, _TimeoutMsg} -> |
|
|
|
doPAL(LeftActions, CallbackForm, CycleData, Debug, IsPostpone, IsHibernate, DoAfter, [OneAction | Timeouts], NextEvents); |
|
|
|
{eTimeout, _Time, _TimeoutMsg, _Options} -> |
|
|
|
doPAL(LeftActions, CallbackForm, CycleData, Debug, IsPostpone, IsHibernate, DoAfter, [OneAction | Timeouts], NextEvents); |
|
|
|
{sTimeout, _Time, _TimeoutMsg, _Options} -> |
|
|
|
doPAL(LeftActions, CallbackForm, CycleData, Debug, IsPostpone, IsHibernate, DoAfter, [OneAction | Timeouts], NextEvents); |
|
|
|
{{gTimeout, _Name}, _Time, _TimeoutMsg, _Options} -> |
|
|
|
doPAL(LeftActions, CallbackForm, CycleData, Debug, IsPostpone, IsHibernate, DoAfter, [OneAction | Timeouts], NextEvents); |
|
|
|
{u_eTimeout, _TimeoutMsg} -> |
|
|
|
doPAL(LeftActions, CallbackForm, CycleData, Debug, IsPostpone, IsHibernate, DoAfter, [OneAction | Timeouts], NextEvents); |
|
|
|
{u_sTimeout, _TimeoutMsg} -> |
|
|
|
doPAL(LeftActions, CallbackForm, CycleData, Debug, IsPostpone, IsHibernate, DoAfter, [OneAction | Timeouts], NextEvents); |
|
|
|
{{u_gTimeout, _Name}, _TimeoutMsg} -> |
|
|
|
doPAL(LeftActions, CallbackForm, CycleData, Debug, IsPostpone, IsHibernate, DoAfter, [OneAction | Timeouts], NextEvents); |
|
|
|
%case OneAction of |
|
|
|
c_eTimeout -> |
|
|
|
doPAL(LeftActions, CallbackForm, CycleData, Debug, IsPostpone, IsHibernate, DoAfter, [OneAction | Timeouts], NextEvents); |
|
|
|
c_sTimeout -> |
|
|
|
doPAL(LeftActions, CallbackForm, CycleData, Debug, IsPostpone, IsHibernate, DoAfter, [OneAction | Timeouts], NextEvents); |
|
|
|
{c_gTimeout, _Name} -> |
|
|
|
doPAL(LeftActions, CallbackForm, CycleData, Debug, IsPostpone, IsHibernate, DoAfter, [OneAction | Timeouts], NextEvents); |
|
|
|
{isHibernate, NewIsHibernate} -> |
|
|
|
doPAL(LeftActions, CallbackForm, CycleData, Debug, IsPostpone, NewIsHibernate, DoAfter, Timeouts, NextEvents); |
|
|
|
{isPostpone, NewIsPostpone} -> |
|
|
|
doPAL(LeftActions, CallbackForm, CycleData, Debug, NewIsPostpone, IsHibernate, DoAfter, Timeouts, NextEvents); |
|
|
|
{doAfter, Args} -> |
|
|
|
doPAL(LeftActions, CallbackForm, CycleData, Debug, IsPostpone, IsHibernate, {true, Args}, Timeouts, NextEvents); |
|
|
|
{nextEvent, Type, Content} -> |
|
|
|
%% 处理next_event动作 |
|
|
|
doPAL(LeftActions, CallbackForm, CycleData, Debug, IsPostpone, IsHibernate, DoAfter, Timeouts, [{Type, Content} | NextEvents]) |
|
|
|
%_ -> |
|
|
|
%case OneAction of |
|
|
|
% c_eTimeout when CallbackForm == 1 -> |
|
|
|
% doPAL(LeftActions, CallbackForm, CycleData, Debug, IsPostpone, IsHibernate, DoAfter, [OneAction | Timeouts], NextEvents); |
|
|
|
% c_sTimeout when CallbackForm == 1 -> |
|
|
|
% doPAL(LeftActions, CallbackForm, CycleData, Debug, IsPostpone, IsHibernate, DoAfter, [OneAction | Timeouts], NextEvents); |
|
|
|
% {c_gTimeout, _Name} when CallbackForm == 1 -> |
|
|
|
% doPAL(LeftActions, CallbackForm, CycleData, Debug, IsPostpone, IsHibernate, DoAfter, [OneAction | Timeouts], NextEvents); |
|
|
|
% {isHibernate, NewIsHibernate} -> |
|
|
|
% doPAL(LeftActions, CallbackForm, CycleData, Debug, IsPostpone, NewIsHibernate, DoAfter, Timeouts, NextEvents); |
|
|
|
% {isPostpone, NewIsPostpone} when (not NewIsPostpone orelse CallbackForm == 1) -> |
|
|
|
% doPAL(LeftActions, CallbackForm, CycleData, Debug, NewIsPostpone, IsHibernate, DoAfter, Timeouts, NextEvents); |
|
|
|
% {doAfter, Args} when CallbackForm == 1 -> |
|
|
|
% doPAL(LeftActions, CallbackForm, CycleData, Debug, IsPostpone, IsHibernate, {true, Args}, Timeouts, NextEvents); |
|
|
|
% {nextEvent, Type, Content} when CallbackForm == 1 orelse CallbackForm == 2 -> |
|
|
|
% %% 处理next_event动作 |
|
|
|
% doPAL(LeftActions, CallbackForm, CycleData, Debug, IsPostpone, IsHibernate, DoAfter, Timeouts, [{Type, Content} | NextEvents]); |
|
|
|
% _ActRet -> |
|
|
|
% doPAL(LeftActions, CallbackForm, CycleData, Debug, IsPostpone, IsHibernate, DoAfter, Timeouts, NextEvents) |
|
|
|
%end |
|
|
|
end. |
|
|
|
|
|
|
|
doPAL2([], _CallbackForm, CycleData, Debug, IsPostpone, IsHibernate, DoAfter, Timeouts, NextEvents) -> |
|
|
|
{CycleData, Debug, IsPostpone, IsHibernate, DoAfter, Timeouts, NextEvents}; |
|
|
|
doPAL2([OneAction | LeftActions], CallbackForm, CycleData, Debug, IsPostpone, IsHibernate, DoAfter, Timeouts, NextEvents) -> |
|
|
|
case OneAction of |
|
|
|
{reply, From, Reply} -> |
|
|
|
doPAL2(LeftActions, CallbackForm, CycleData, Debug, IsPostpone, IsHibernate, DoAfter, Timeouts, NextEvents); |
|
|
|
{eTimeout, _Time, _TimeoutMsg} when CallbackForm == 1 -> |
|
|
|
doPAL2(LeftActions, CallbackForm, CycleData, Debug, IsPostpone, IsHibernate, DoAfter, [OneAction | Timeouts], NextEvents); |
|
|
|
{sTimeout, _Time, _TimeoutMsg} -> |
|
|
|
doPAL2(LeftActions, CallbackForm, CycleData, Debug, IsPostpone, IsHibernate, DoAfter, [OneAction | Timeouts], NextEvents); |
|
|
|
{{gTimeout, _Name}, _Time, _TimeoutMsg} -> |
|
|
|
doPAL2(LeftActions, CallbackForm, CycleData, Debug, IsPostpone, IsHibernate, DoAfter, [OneAction | Timeouts], NextEvents); |
|
|
|
{c_gTimeout, _Name} when CallbackForm == 1 -> |
|
|
|
doPAL2(LeftActions, CallbackForm, CycleData, Debug, IsPostpone, IsHibernate, DoAfter, [OneAction | Timeouts], NextEvents); |
|
|
|
{eTimeout, _Time, _TimeoutMsg, _Options} -> |
|
|
|
doPAL2(LeftActions, CallbackForm, CycleData, Debug, IsPostpone, IsHibernate, DoAfter, [OneAction | Timeouts], NextEvents); |
|
|
|
{sTimeout, _Time, _TimeoutMsg, _Options} -> |
|
|
|
doPAL2(LeftActions, CallbackForm, CycleData, Debug, IsPostpone, IsHibernate, DoAfter, [OneAction | Timeouts], NextEvents); |
|
|
|
{{gTimeout, _Name}, _Time, _TimeoutMsg, _Options} -> |
|
|
|
doPAL2(LeftActions, CallbackForm, CycleData, Debug, IsPostpone, IsHibernate, DoAfter, [OneAction | Timeouts], NextEvents); |
|
|
|
{u_eTimeout, _TimeoutMsg} when CallbackForm == 1 -> |
|
|
|
doPAL2(LeftActions, CallbackForm, CycleData, Debug, IsPostpone, IsHibernate, DoAfter, [OneAction | Timeouts], NextEvents); |
|
|
|
{u_sTimeout, _TimeoutMsg} -> |
|
|
|
doPAL2(LeftActions, CallbackForm, CycleData, Debug, IsPostpone, IsHibernate, DoAfter, [OneAction | Timeouts], NextEvents); |
|
|
|
{{u_gTimeout, _Name}, _TimeoutMsg} -> |
|
|
|
doPAL2(LeftActions, CallbackForm, CycleData, Debug, IsPostpone, IsHibernate, DoAfter, [OneAction | Timeouts], NextEvents); |
|
|
|
c_eTimeout when CallbackForm == 1 -> |
|
|
|
doPAL2(LeftActions, CallbackForm, CycleData, Debug, IsPostpone, IsHibernate, DoAfter, [OneAction | Timeouts], NextEvents); |
|
|
|
c_sTimeout when CallbackForm == 1 -> |
|
|
|
doPAL2(LeftActions, CallbackForm, CycleData, Debug, IsPostpone, IsHibernate, DoAfter, [OneAction | Timeouts], NextEvents); |
|
|
|
{c_gTimeout, _Name} when CallbackForm == 1 -> |
|
|
|
doPAL2(LeftActions, CallbackForm, CycleData, Debug, IsPostpone, IsHibernate, DoAfter, [OneAction | Timeouts], NextEvents); |
|
|
|
{isHibernate, NewIsHibernate} -> |
|
|
|
doPAL2(LeftActions, CallbackForm, CycleData, Debug, IsPostpone, NewIsHibernate, DoAfter, Timeouts, NextEvents); |
|
|
|
{isPostpone, NewIsPostpone} when (not NewIsPostpone orelse CallbackForm == 1) -> |
|
|
|
doPAL2(LeftActions, CallbackForm, CycleData, Debug, NewIsPostpone, IsHibernate, DoAfter, Timeouts, NextEvents); |
|
|
|
{doAfter, Args} when CallbackForm == 1 -> |
|
|
|
doPAL2(LeftActions, CallbackForm, CycleData, Debug, IsPostpone, IsHibernate, {true, Args}, Timeouts, NextEvents); |
|
|
|
{nextEvent, Type, Content} when CallbackForm == 1 orelse CallbackForm == 2 -> |
|
|
|
%% 处理next_event动作 |
|
|
|
doPAL2(LeftActions, CallbackForm, CycleData, Debug, IsPostpone, IsHibernate, DoAfter, Timeouts, [{Type, Content} | NextEvents]); |
|
|
|
_ActRet -> |
|
|
|
doPAL2(LeftActions, CallbackForm, CycleData, Debug, IsPostpone, IsHibernate, DoAfter, Timeouts, NextEvents) |
|
|
|
end. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|