Re: do_initialization() example

Dieter Schön <[email protected]>
Newsgroups gmane.comp.lang.erlang.general
Message-ID <[email protected]>
Dear Peter,

as I see it, this code is just an example that shows how to initialize a 
custom process/module

which adheres to OTP.

The function do_initialization() is just a placeholder and depends on 
the topic of your module.

This could be anything from contacting a database to initializing an I2C 
link.

Here it is only known that it either returns ok or {error, Reason}. 
Based on this, the startup

either succeeds or fails.


In general, if you are looking for examples, I suggest to search on 
github or similar, something like

https://github.com/search?q=proc_lib%3Ainit_ack&type=commits



Kind regards,

Dieter


On 01.01.21 06:32, Peter J Etheridge wrote:
> Dear Fellow Erlangers,
>
> In proc_lib module this example includes a function in the case statement;
>
> -module(my_proc).
> -export([start_link/0]).
> -export([init/1]).
>
> start_link() ->
>      proc_lib:start_link(my_proc, init, [self()])
>
> init(Parent) ->
>      case  do_initialization()of
>          ok ->
>              proc_lib:init_ack(Parent, {ok, self()});
>          {error, Reason} ->
>              exit(Reason)
>      end,
>      loop().
>
>
> could someone kindly direct me to an example of a
>
> do_initialization()
>
> function?
>
> thank you in advance,
>
> Peter
>
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.