Guest User

Untitled

a guest
Feb 19th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. % version 1
  2. -module(code_change_test).
  3. -behaviour(gen_server).
  4.  
  5. -export([start/0, stop/0]).
  6. -export([state/0]).
  7.  
  8. -export([
  9. init/1,
  10. handle_call/3, handle_cast/2, handle_info/2,
  11. terminate/2, code_change/3
  12. ]).
  13.  
  14. start() -> gen_server:start({local, ?MODULE}, ?MODULE, [], []).
  15. stop() -> gen_server:cast(?MODULE, stop).
  16. state() -> gen_server:call(?MODULE, state).
  17.  
  18. init(_Args) ->
  19. {ok, ver1}.
  20.  
  21. handle_call(state, _From, State) ->
  22. io:fwrite("State=~p~n", [State]),
  23. {reply, State, State};
  24. handle_call(_Message, _From, State) ->
  25. {reply, ok, State}.
  26.  
  27. handle_cast(stop, State) ->
  28. {stop, normal, State};
  29. handle_cast(_Message, State) ->
  30. {noreply, State}.
  31.  
  32. handle_info(_Info, State) -> {noreply, State}.
  33.  
  34. terminate(normal, _State) -> ok;
  35. terminate(_, _) -> ok.
  36.  
  37. code_change(_OldVsn, State, _Extra) ->
  38. {ok, State}.
Add Comment
Please, Sign In to add comment