Is there a way to make_ref() for spawned processes in erlang?

65 views Asked by At

I have tried to make references to spawned processes in erlang in several ways in order to make them compatible with the logging of From in a call to gen_server. So far I have tried P1ID = {spawn(fun() -> self() end), make_ref()}, in order to capture the structure of from() as stated in the documentation about gen_server:reply: erlang documentation I have not yet succeeded and the documentation about make_ref() is rather scarce.

1

There are 1 answers

2
Dan Filip On

were you attempting to built that {Pid, Ref} tuple in order to test the handle_call() gen_server callback from your tests?

if yes, you should not test these gen_server internals directly. instead add higher level functions to your module(that will call the gen_server call/cast/.. functions) and test those

spawn() already returns a pid() so there was no reason to return self() from from the spawned process.

Hope it helps