Skip to content

Instantly share code, notes, and snippets.

@santosh79
Created February 6, 2015 17:52
Show Gist options
  • Save santosh79/8a45719d827571366b14 to your computer and use it in GitHub Desktop.
Save santosh79/8a45719d827571366b14 to your computer and use it in GitHub Desktop.
find_broken_links(Urls) ->
lists:foreach(fun(Url) -> spawn(url_checker, is_working_url, [self(), Url]) end, Urls)
get_results(length(Urls)).
get_results(N) -> get_results(0, N, []).
get_results(N, N, BrokenLinks) -> {ok, BrokenLinks};
get_results(Cnt, N, BrokenLinks) ->
receive
{_Client, Url, true} -> get_results(Cnt + 1, N, BrokenLinks);
{_Client, Url, false} -> get_results(Cnt + 1, N, [Url|BrokenLinks])
end.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment