aboutsummaryrefslogtreecommitdiffstats
path: root/lib/kernel/src/application.erl
diff options
context:
space:
mode:
authorBjörn-Egil Dahlberg <[email protected]>2013-03-12 16:57:44 +0100
committerBjörn-Egil Dahlberg <[email protected]>2013-03-12 16:57:44 +0100
commit4955bf98ead49b0c7122ab30e462f9b817bd5c6e (patch)
tree077db4ce10c5ef45657c908b4f11ec61bf94ae99 /lib/kernel/src/application.erl
parent6e445498dfa736090f3080484204b65a1ca25703 (diff)
parent7bfa1947ba60d61fd1bb8040f435e4dcaefac32a (diff)
downloadotp-4955bf98ead49b0c7122ab30e462f9b817bd5c6e.tar.gz
otp-4955bf98ead49b0c7122ab30e462f9b817bd5c6e.tar.bz2
otp-4955bf98ead49b0c7122ab30e462f9b817bd5c6e.zip
Merge branch 'egil/kernel/application-ensure_started/OTP-10910' into maint
* egil/kernel/application-ensure_started/OTP-10910: kernel: Document application:ensure_started/1,2 tests: Refactor away ?line macro in test suite kernel: Tests for application:ensure_started/1,2 kernel: Add application:ensure_started/1,2
Diffstat (limited to 'lib/kernel/src/application.erl')
-rw-r--r--lib/kernel/src/application.erl23
1 files changed, 23 insertions, 0 deletions
diff --git a/lib/kernel/src/application.erl b/lib/kernel/src/application.erl
index 6efc1b4499..5dd6b73857 100644
--- a/lib/kernel/src/application.erl
+++ b/lib/kernel/src/application.erl
@@ -22,6 +22,7 @@
load/1, load/2, unload/1, takeover/2,
which_applications/0, which_applications/1,
loaded_applications/0, permit/2]).
+-export([ensure_started/1, ensure_started/2]).
-export([set_env/3, set_env/4, unset_env/2, unset_env/3]).
-export([get_env/1, get_env/2, get_env/3, get_all_env/0, get_all_env/1]).
-export([get_key/1, get_key/2, get_all_key/0, get_all_key/1]).
@@ -135,6 +136,28 @@ start(Application, RestartType) ->
Error
end.
+-spec ensure_started(Application) -> 'ok' | {'error', Reason} when
+ Application :: atom(),
+ Reason :: term().
+
+ensure_started(Application) ->
+ ensure_started(Application, temporary).
+
+-spec ensure_started(Application, Type) -> 'ok' | {'error', Reason} when
+ Application :: atom(),
+ Type :: restart_type(),
+ Reason :: term().
+
+ensure_started(Application, RestartType) ->
+ case start(Application, RestartType) of
+ ok ->
+ ok;
+ {error, {already_started, Application}} ->
+ ok;
+ Error ->
+ Error
+ end.
+
-spec start_boot(Application :: atom()) -> 'ok' | {'error', term()}.
start_boot(Application) ->