11-module (elixir_code_server ).
2+ -export ([call /1 , cast /1 ]).
23-export ([start_link /0 , init /1 , handle_call /3 , handle_cast /2 ,
34 handle_info /2 , terminate /2 , code_change /3 ]).
45-behavior (gen_server ).
1213 waiting = []
1314}).
1415
16+ call (Args ) ->
17+ gen_server :call (? MODULE , Args , get_timeout ()).
18+
19+ cast (Args ) ->
20+ gen_server :cast (? MODULE , Args ).
21+
22+ get_timeout () ->
23+ 30000 .
24+
25+ % % Callbacks
26+
1527start_link () ->
16- { ok , _ } = gen_server :start_link ({local , elixir_code_server }, ? MODULE , [], []).
28+ { ok , _ } = gen_server :start_link ({local , ? MODULE }, ? MODULE , [], []).
1729
1830init (_args ) ->
1931 { ok , # elixir_code_server {} }.
@@ -38,16 +50,6 @@ handle_call({ acquire, Path }, From, Config) ->
3850 { reply , proceed , Config # elixir_code_server {loaded = Queued } }
3951 end ;
4052
41- handle_call ({ at_exit , AtExit }, _From , Config ) ->
42- { reply , ok , Config # elixir_code_server {at_exit = [AtExit |Config # elixir_code_server .at_exit ]} };
43-
44- handle_call ({ argv , Argv }, _From , Config ) ->
45- { reply , ok , Config # elixir_code_server {argv = Argv } };
46-
47- handle_call ({ compiler_options , Options }, _From , Config ) ->
48- Final = orddict :merge (fun (_ ,_ ,V ) -> V end , Config # elixir_code_server .compiler_options , Options ),
49- { reply , ok , Config # elixir_code_server {compiler_options = Final } };
50-
5153handle_call (loaded , _From , Config ) ->
5254 { reply , [F || { F , true } <- Config # elixir_code_server .loaded ], Config };
5355
@@ -75,6 +77,16 @@ handle_call(retrieve_module_name, _From, Config) ->
7577handle_call (_Request , _From , Config ) ->
7678 { reply , undef , Config }.
7779
80+ handle_cast ({ at_exit , AtExit }, Config ) ->
81+ { noreply , Config # elixir_code_server {at_exit = [AtExit |Config # elixir_code_server .at_exit ]} };
82+
83+ handle_cast ({ argv , Argv }, Config ) ->
84+ { noreply , Config # elixir_code_server {argv = Argv } };
85+
86+ handle_cast ({ compiler_options , Options }, Config ) ->
87+ Final = orddict :merge (fun (_ ,_ ,V ) -> V end , Config # elixir_code_server .compiler_options , Options ),
88+ { noreply , Config # elixir_code_server {compiler_options = Final } };
89+
7890handle_cast (finished , Config ) ->
7991 Waiting = Config # elixir_code_server .waiting ,
8092 [Pid ! { elixir_code_server , finished } || Pid <- lists :reverse (Waiting )],
0 commit comments