Skip to content

Commit 00ab3c6

Browse files
committed
Add spawn_monitor/1, /3
Signed-off-by: Jakub Gonet <jakub.gonet@swmansion.com>
1 parent bafd18b commit 00ab3c6

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2222
- Added support for `ets:update_counter/3` and `ets:update_counter/4`.
2323
- Added `erlang:+/1`
2424
- Added `lists:append/1` and `lists:append/2`
25+
- Added `erlang:spawn_monitor/1`, `erlang:spawn_monitor/3`
2526

2627
### Fixed
2728
- ESP32: improved sntp sync speed from a cold boot.

libs/estdlib/src/erlang.erl

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@
8282
spawn/3,
8383
spawn_link/1,
8484
spawn_link/3,
85+
spawn_monitor/1,
86+
spawn_monitor/3,
8587
spawn_opt/2,
8688
spawn_opt/4,
8789
link/1,
@@ -929,6 +931,29 @@ spawn_link(Function) ->
929931
spawn_link(Module, Function, Args) ->
930932
erlang:spawn_opt(Module, Function, Args, [link]).
931933

934+
%%-----------------------------------------------------------------------------
935+
%% @param Function function to create a process from
936+
%% @returns pid of the new process
937+
%% @doc Create a new process and monitor it.
938+
%% @end
939+
%%-----------------------------------------------------------------------------
940+
-spec spawn_monitor(Function :: function()) -> pid().
941+
spawn_monitor(Function) ->
942+
erlang:spawn_opt(Function, [monitor]).
943+
944+
%%-----------------------------------------------------------------------------
945+
%% @param Module module of the function to create a process from
946+
%% @param Function name of the function to create a process from
947+
%% @param Args arguments to pass to the function to create a process from
948+
%% @returns pid of the new process
949+
%% @doc Create a new process by calling exported Function from Module with Args
950+
%% and monitor it.
951+
%% @end
952+
%%-----------------------------------------------------------------------------
953+
-spec spawn_monitor(Module :: module(), Function :: atom(), Args :: [any()]) -> pid().
954+
spawn_monitor(Module, Function, Args) ->
955+
erlang:spawn_opt(Module, Function, Args, [monitor]).
956+
932957
%%-----------------------------------------------------------------------------
933958
%% @param Function function to create a process from
934959
%% @param Options additional options.

0 commit comments

Comments
 (0)