Make Module.open?/1 and family to match their docs (#9278)

* Make Module.open?/1 and family to match their docs.

* Cosmetics.

* Introduced internal not_closing state for modules.

It’s stored in a separate ETS and the last field of #elixir_code_server state to minimize impact.

* Use the same ETS for the state.
This commit is contained in:
Aleksei Matiushkin
2019-08-09 15:43:43 +02:00
committed by José Valim
parent 885b886982
commit 9a959eac25
4 changed files with 68 additions and 9 deletions
+12
View File
@@ -40,6 +40,9 @@ handle_call({defmodule, Module, Pid, Tuple}, _From, Config) ->
handle_call({undefmodule, Ref}, _From, Config) ->
{reply, ok, undefmodule(Ref, Config)};
handle_call({unopenmodule, Ref}, _From, Config) ->
{reply, ok, unopenmodule(Ref, Config)};
handle_call({acquire, Path}, From, Config) ->
Current = Config#elixir_code_server.required,
case maps:find(Path, Current) of
@@ -155,3 +158,12 @@ undefmodule(Ref, #elixir_code_server{mod_ets=ModEts} = Config) ->
error ->
Config
end.
unopenmodule(Ref, #elixir_code_server{mod_ets=ModEts} = Config) ->
case maps:find(Ref, ModEts) of
{ok, Mod} ->
ets:update_element(elixir_modules, Mod, {5, false}),
Config;
error ->
Config
end.