An erlang progress bar module really should support concurrency. You should be able to have multiple processes notifying the progress bar of the completion of their task. The progress bar should notify those waiting for completion, pregnancy etc. So - time for an update!
Now you can start a progress bar server and easily run tasks in parallel. To see a sample use:
progress_bar:example_processes( 1000, 10 ).
That’s just starting a progress server and calling increment server:
example_processes(N, P) -> start_server(”Example“, N), for(1, P, fun() -> spawn_link( fun() -> example_work_process(N div P) end ) end ), receive finished -> finished end. example_work_process(0) -> void; example_work_process(N) -> timer:sleep(100), increment_server(), example_work_process(N-1). for(N, N, F) -> [F()]; for(I, N, F) -> [F()|for(I+1, N, F)]
Dan Bravender was kind enough to point out that if we change the record name to the same as the module name we can use it in a more object oriented fashion… so PBar:finish instead of progress_bar:finish(PBar). Thanks Dan.
Also - github’s new “gist” is awesome. It lets you create code snippets that are git repositories. Perfect for tiny little erlang modules like this! So you can now get the progress bar from git://gist.github.com/58.git or just download it from here