Skip to content

Instantly share code, notes, and snippets.

@Fonsan
Last active August 29, 2015 14:08
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 Fonsan/69a2b14f079b4885ef2a to your computer and use it in GitHub Desktop.
Save Fonsan/69a2b14f079b4885ef2a to your computer and use it in GitHub Desktop.
parallel_fetch(ServerPid, FirstKey, SecondKey, ThirdKey) ->
FirstRequestId = make_ref(),
SecondRequestId = make_ref(),
ThirdRequestId = make_ref(),
ServerPid ! {self(), FirstRequestId, FirstKey},
ServerPid ! {self(), SecondRequestId, SecondKey},
ServerPid ! {self(), ThirdRequestId, Thirdkey},
FirstValue = receive
{FirstRequestId, FirstResult} -> FirstResult
end,
SecondValue = receive
{SecondRequestId, SecondResult} -> SecondResult
end,
ThirdValue = receive
{ThirdRequestId, ThirdResult} -> ThirdResult
end,
{FirstResult, SecondResult, ThirdResult}.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment