Skip to content

Instantly share code, notes, and snippets.

@abhijitiitr
Created October 23, 2014 21:54
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 abhijitiitr/b1b6f32079b869fef046 to your computer and use it in GitHub Desktop.
Save abhijitiitr/b1b6f32079b869fef046 to your computer and use it in GitHub Desktop.
% c(spawner).
% c(conc_nif_caller).
% c(niftest).
% spawn(spawner,spawn_multiple_nif_callers,[10]).
-module(spawner).
-export([spawn_multiple_nif_callers/1]).
spawn_multiple_nif_callers(Val) ->
FinalPidList = lists:foldl(fun(Int_Pid, PidList) ->
Pid = spawn(conc_nif_caller, call_nif, []),
[{Int_Pid, Pid} | PidList]
end,[], lists:seq(1,Val)),
lists:foreach(fun(Elem) ->
{A, B} = Elem,
B ! A
end, FinalPidList).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment