Skip to content

Instantly share code, notes, and snippets.

@sleeptillseven
Created December 15, 2011 20:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sleeptillseven/1482622 to your computer and use it in GitHub Desktop.
Save sleeptillseven/1482622 to your computer and use it in GitHub Desktop.
spawning a lot of processes
-module(ring).
-export([start/1]).
-export([start_proc/2]).
start(Num) ->
start_proc(Num, self()).
start_proc(0, Pid) ->
Pid ! ok;
start_proc(Num, Pid) ->
NPid = spawn(ring, start_proc, [Num -1, Pid]),
NPid ! ok,
receive
ok -> ok
end.
@sleeptillseven
Copy link
Author

When I run ring:start(0) it works. But when I put a number bigger than 0 I get the following error:

Error in process <0.39.0> with exit value: {undef,[{ring,start_proc,[9,<0.31.0>]}]}

No idea what is wrong. Any help is welcome.

@sleeptillseven
Copy link
Author

Forgot to export the underlying function.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment