1
1
-module (elixir_code_server ).
2
+ -export ([call /1 , cast /1 ]).
2
3
-export ([start_link /0 , init /1 , handle_call /3 , handle_cast /2 ,
3
4
handle_info /2 , terminate /2 , code_change /3 ]).
4
5
-behavior (gen_server ).
12
13
waiting = []
13
14
}).
14
15
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
+
15
27
start_link () ->
16
- { ok , _ } = gen_server :start_link ({local , elixir_code_server }, ? MODULE , [], []).
28
+ { ok , _ } = gen_server :start_link ({local , ? MODULE }, ? MODULE , [], []).
17
29
18
30
init (_args ) ->
19
31
{ ok , # elixir_code_server {} }.
@@ -38,16 +50,6 @@ handle_call({ acquire, Path }, From, Config) ->
38
50
{ reply , proceed , Config # elixir_code_server {loaded = Queued } }
39
51
end ;
40
52
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
-
51
53
handle_call (loaded , _From , Config ) ->
52
54
{ reply , [F || { F , true } <- Config # elixir_code_server .loaded ], Config };
53
55
@@ -75,6 +77,16 @@ handle_call(retrieve_module_name, _From, Config) ->
75
77
handle_call (_Request , _From , Config ) ->
76
78
{ reply , undef , Config }.
77
79
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
+
78
90
handle_cast (finished , Config ) ->
79
91
Waiting = Config # elixir_code_server .waiting ,
80
92
[Pid ! { elixir_code_server , finished } || Pid <- lists :reverse (Waiting )],
0 commit comments