[erlang-questions] OTP Question

Ladislav Lenart lenartlad@REDACTED
Thu Nov 22 15:18:36 CET 2012


Hello.

I assume you are referring to an attribute such as this:

    -module(example).
    -behaviour(gen_server). %% <--
    ...

The module 'example' is a callback MODULE (i.e. a code). It supplies
application-specific logic to the generic gen_server process. There is only one
process, the gen_server. It calls functions from your callback module for
specific events, such as initialization, termination, receiving of a message,
code change and such. You only implement the application-specific portion and
don't need to know details of the underlying gen_server implementation. For
example gen_server:call/X as implemented by the gen_server contains logic that:
 * detects a call to a nonexistent process,
 * monitors the gen_server process being called during the entire call request
to detect unexpected gen_server termination or a network failure.

With the above in mind...

> - Is the behavior process in OTP a child process? and
No. gen_server module and an application-specific behavior module together
implement ONE process.

> - Are callback functions executed in the parent or child process?

They are executed in the gen_server process, see above.


HTH,

Ladislav Lenart


On 22.11.2012 14:54, Lucky Khoza wrote:
> Hi Erlang Developers,
> 
> May someone help me understand the following:
> 
> - Is the behavior process in OTP a child process? and
> - Are callback functions executed in the parent or child process?
> 
> Kindest Regards
> Lucky Khoza
> 
> 
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions




More information about the erlang-questions mailing list