diff options
author | Vlad Dumitrescu <[email protected]> | 2013-02-01 22:16:09 +0100 |
---|---|---|
committer | Vlad Dumitrescu <[email protected]> | 2013-02-01 22:16:09 +0100 |
commit | c14a046f40dee9915aa2d3d7d351bd80a630db61 (patch) | |
tree | 8b6693ec8bb329eabf4875898754061f846bb2a3 /lib/kernel/src | |
parent | 68b804f34d4ec420d86953e3f519179a40fbee8f (diff) | |
download | otp-c14a046f40dee9915aa2d3d7d351bd80a630db61.tar.gz otp-c14a046f40dee9915aa2d3d7d351bd80a630db61.tar.bz2 otp-c14a046f40dee9915aa2d3d7d351bd80a630db61.zip |
Add a new function code:get_mode() can be used to detect how the code servers behaves
Rationale:
Some applications (like erlide) have code to be loaded dynamically on a
node. It may be slow to load everything upfront every time, so if the
node is in interactive mode, we would like to just append to the load
path. Currently, there is no direct way to detect if the node is running
in embedded mode or not so that we can do the right thing.
Diffstat (limited to 'lib/kernel/src')
-rw-r--r-- | lib/kernel/src/code.erl | 6 | ||||
-rw-r--r-- | lib/kernel/src/code_server.erl | 3 |
2 files changed, 8 insertions, 1 deletions
diff --git a/lib/kernel/src/code.erl b/lib/kernel/src/code.erl index 8a543abd6f..03fba96d4b 100644 --- a/lib/kernel/src/code.erl +++ b/lib/kernel/src/code.erl @@ -64,7 +64,8 @@ where_is_file/1, where_is_file/2, set_primary_archive/4, - clash/0]). + clash/0, + get_mode/0]). -export_type([load_error_rsn/0, load_ret/0]). @@ -293,6 +294,9 @@ replace_path(Name, Dir) when (is_atom(Name) orelse is_list(Name)), -spec rehash() -> 'ok'. rehash() -> call(rehash). +-spec get_mode() -> 'embedded' | 'interactive'. +get_mode() -> call(get_mode). + %%----------------------------------------------------------------- call(Req) -> diff --git a/lib/kernel/src/code_server.erl b/lib/kernel/src/code_server.erl index b770fce887..5d74e8620b 100644 --- a/lib/kernel/src/code_server.erl +++ b/lib/kernel/src/code_server.erl @@ -422,6 +422,9 @@ handle_call({is_cached,File}, {_From,_Tag}, S=#state{cache=Cache}) -> end end; +handle_call(get_mode, {_From,_Tag}, S=#state{mode=Mode}) -> + {reply, Mode, S}; + handle_call(Other,{_From,_Tag}, S) -> error_msg(" ** Codeserver*** ignoring ~w~n ",[Other]), {noreply,S}. |