Skip to content

Commit

Permalink
worker for event handler
Browse files Browse the repository at this point in the history
  • Loading branch information
peiyangli committed Aug 28, 2019
1 parent d5f6d50 commit db1df67
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/workitem_worker.erl
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,8 @@ handle_call({on, Fun}, _From, State) ->
NewState ->
{reply, noreply, NewState}
end;
handle_call(Request, From, State = #{handle := MFA}) ->
handle_X(MFA, call, {Request, From}, State);
handle_call(_Request, _From, State) ->
{reply, ok, State}.

Expand All @@ -169,13 +171,25 @@ handle_cast({on, Fun}, State) ->
NewState ->
{noreply, NewState}
end;
handle_cast(Info, State = #{handle := MFA}) ->
handle_X(MFA, cast, Info, State);
handle_cast(_Request, State) ->
{noreply, State}.

handle_info(Info, State = #{handle := MFA}) ->
handle_X(MFA, info, Info, State);
%% M:F(info, Info, State, A);
%% {noreply, State};
handle_info(_Info, State) ->
{noreply, State}.


handle_X({M,F,A}, X, What, State)->
M:F(X, What, State, A);
handle_X({M,F}, X, What, State)->
M:F(X, What, State).


terminate(_Reason, _State) ->
ok.

Expand Down

0 comments on commit db1df67

Please sign in to comment.