Skip to content

Commit

Permalink
Update docs with code example.
Browse files Browse the repository at this point in the history
  • Loading branch information
g-andrade committed Apr 3, 2015
1 parent 9a0396b commit d6a170e
Show file tree
Hide file tree
Showing 15 changed files with 115 additions and 13 deletions.
29 changes: 29 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,37 @@ Copyright (c) 2015 Guilherme Andrade
__Version:__ 1.0.0

__Authors:__ Guilherme Andrade ([`g@gandrade.net`](mailto:g@gandrade.net)).

`taskforce` allows you to parallelise arbitrary tasks in a controlled way.

---------


```erlang

application:ensure_all_started(taskforce).
IndividualTimeoutT = 100. % in miliseconds
GlobalTimeoutT = 3000. % in miliseconds
MinionCount = 4. % 4 workers

% dirty factorial
FactFun = fun(N) -> lists:foldl(fun erlang:'*'/2, 1, lists:seq(1, N)) end.

Tasks = [taskforce:new_task({fact, V}, FactFun, [V], IndividualTimeoutT)
|| V <- lists:seq(1, 3000)].

{ResultsById, Individualtimeouts, GlobalTimeouts} = taskforce:execute_tasks(
Tasks, GlobalTimeoutT, MinionCount).

rp(ResultsById).
% ...
% {{fact,1612},
% 155786735261829320722603634295521850549712997645292036744792078980324992080829520333637579356940021229269734555860899020135935926348738260274025884311572034997502605793835116829517075042962020336842294623372114891550621741227961590670666503556615927286307669915307416781170961816011223693599198638158655601788154923003840306479922838700449825023318474541364073269283779463774974414341010643656346570408165667718001801057557149978132222908297075885771757780095581512503464731797682668265258265660033705560137062630226988053365643176778660826718671905541604970208092965866447134353417940319949313631213418079923067731991247257565003936414027524677043363017709934421867473421824438557653800903487098193417728043085612330645749156333383094345942266405423161221384714043609762828612806439669557254921883510897202624326149505953723642369064760919035687971795152264873362873341172714124628456144001984158991169373814466854781378836145324880791973886445283088579468775740929096645785616509544620890014365718395103272508063613141021009561849132148833497958498746715377680174883841777868749956245365383672522150677505564924004272980732609677036258786106944724532240639032902765783012900038587266385478002824145754422068108960323019713831513444101234041802892228532816797657720926218423933730780350318726561535712112646101044056582512608050716659579654240107655808676572293137600978542619651764177786082298667859791086005189412815457018510480877257963423562294439181061021155376466976732753114963089332658724570646571055545272353241666937188632628395983960802397614646382421090184827994732170015852514960263477734819739200271890932190194311426485039632544473234467451553124963152777480300656435286758368532645873608039146657288143290407620370093032093894974172271758864765979271530423288675474843653206752360747492550764034045917458369942729127483700638440421528536777404252831531346640088799958284331751827312657788316769661423896076012065471265472058321414768616712810793034641372873954152609654868006802603434297632765213528539535025132242584167078933571199854441766483289562636899447940956794113921340642845225938053652169926606498830928233716980297848677063008987462525104449173729557044858854290490172514650470850123628065863293538225424918086009262264821551979623171942010654317124852444325459732757440705035563219508430063332214856568561868339321308800341439020004467957410782984558870622838281320427575133423019240832985601140874882499505916780782995915377541400684895549385699982884633908616509397791052013057818090452468856114596220701373810345870197956575569369624949383234581917806852109214734031570338687626620789115972282262266588639905682492048134486287350479594403557965173352464645386479799910791544458710480062498725166089182508941863659724832737999983336341975140830182438441212034848007541015778680281841336819262463744814566392548102016693561742311481764786375569180037790875480111272339425796827332210895445034463256919770842391765105629113558312595974514562460557238682286687149318259942294641573361094550974500209572943354306503601562716495913896901228050771570714968637106631217791621012659597909909050478526027434832953184955003635814102163749146122454284067747334727830471837055561704326351369297999420671941622877518672129495588882885435647614672873761318408673871147163901095715587544013148330949324558820589031231206055418951713741724923044116496063271006546801824500055234790008293506107729917139219694824334149486253303864577333798213281862215717556304395355827589017350344944664142581881996472498187075638152671681649102437312213224150443362681739913997239690861725598045828637648710220779280756868948927935837746370637783855555800576368994739646200971336948619193994684746801219258021733200754145963507769409124110177743736740187343136205527507008496103282722169372876657445820887278256535772129143360324176031872104000224296271558971122719393952754681302252691593321851250276864579879607341769323022142489712922717066168588834755412743353748056501473438752318616987316365797986708672222815506852055321834486714774432656429730164856094562757891850240000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000}
% ..

```



## Modules ##

Expand Down
1 change: 0 additions & 1 deletion doc/edoc-info
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
%% encoding: UTF-8
{application,taskforce}.
{packages,[]}.
{modules,[taskforce,taskforce_app,taskforce_sup,tf_master_serv,tf_master_sup,
tf_minion_serv,tf_minion_sup]}.
2 changes: 1 addition & 1 deletion doc/index.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Application: taskforce</title>
<title>Overview</title>
</head>
<frameset cols="20%,80%">
<frame src="modules-frame.html" name="modulesFrame" title="">
Expand Down
2 changes: 1 addition & 1 deletion doc/modules-frame.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Application: taskforce</title>
<title>Overview</title>
<link rel="stylesheet" type="text/css" href="stylesheet.css" title="EDoc">
</head>
<body bgcolor="white">
Expand Down
27 changes: 25 additions & 2 deletions doc/overview-summary.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,33 @@ <h1>taskforce</h1>
<p>Copyright © 2015 Guilherme Andrade</p>
<p><b>Version:</b> 1.0.0</p>
<p><b>Authors:</b> Guilherme Andrade (<a href="mailto:g@gandrade.net"><tt>g@gandrade.net</tt></a>).</p>
<code>taskforce</code> allows you to parallelise arbitrary tasks in a controlled way.
<p><code>taskforce</code> allows you to parallelise arbitrary tasks in a controlled way.</p>

<hr>
<pre lang="erlang">
application:ensure_all_started(taskforce).
IndividualTimeoutT = 100. % in miliseconds
GlobalTimeoutT = 3000. % in miliseconds
MinionCount = 4. % 4 workers

% dirty factorial
FactFun = fun(N) -&gt; lists:foldl(fun erlang:'*'/2, 1, lists:seq(1, N)) end.

Tasks = [taskforce:new_task({fact, V}, FactFun, [V], IndividualTimeoutT)
|| V &lt;- lists:seq(1, 3000)].

{ResultsById, Individualtimeouts, GlobalTimeouts} = taskforce:execute_tasks(
Tasks, GlobalTimeoutT, MinionCount).

rp(ResultsById).
% ...
% {{fact,1612},
% 155786735261829320722603634295521850549712997645292036744792078980324992080829520333637579356940021229269734555860899020135935926348738260274025884311572034997502605793835116829517075042962020336842294623372114891550621741227961590670666503556615927286307669915307416781170961816011223693599198638158655601788154923003840306479922838700449825023318474541364073269283779463774974414341010643656346570408165667718001801057557149978132222908297075885771757780095581512503464731797682668265258265660033705560137062630226988053365643176778660826718671905541604970208092965866447134353417940319949313631213418079923067731991247257565003936414027524677043363017709934421867473421824438557653800903487098193417728043085612330645749156333383094345942266405423161221384714043609762828612806439669557254921883510897202624326149505953723642369064760919035687971795152264873362873341172714124628456144001984158991169373814466854781378836145324880791973886445283088579468775740929096645785616509544620890014365718395103272508063613141021009561849132148833497958498746715377680174883841777868749956245365383672522150677505564924004272980732609677036258786106944724532240639032902765783012900038587266385478002824145754422068108960323019713831513444101234041802892228532816797657720926218423933730780350318726561535712112646101044056582512608050716659579654240107655808676572293137600978542619651764177786082298667859791086005189412815457018510480877257963423562294439181061021155376466976732753114963089332658724570646571055545272353241666937188632628395983960802397614646382421090184827994732170015852514960263477734819739200271890932190194311426485039632544473234467451553124963152777480300656435286758368532645873608039146657288143290407620370093032093894974172271758864765979271530423288675474843653206752360747492550764034045917458369942729127483700638440421528536777404252831531346640088799958284331751827312657788316769661423896076012065471265472058321414768616712810793034641372873954152609654868006802603434297632765213528539535025132242584167078933571199854441766483289562636899447940956794113921340642845225938053652169926606498830928233716980297848677063008987462525104449173729557044858854290490172514650470850123628065863293538225424918086009262264821551979623171942010654317124852444325459732757440705035563219508430063332214856568561868339321308800341439020004467957410782984558870622838281320427575133423019240832985601140874882499505916780782995915377541400684895549385699982884633908616509397791052013057818090452468856114596220701373810345870197956575569369624949383234581917806852109214734031570338687626620789115972282262266588639905682492048134486287350479594403557965173352464645386479799910791544458710480062498725166089182508941863659724832737999983336341975140830182438441212034848007541015778680281841336819262463744814566392548102016693561742311481764786375569180037790875480111272339425796827332210895445034463256919770842391765105629113558312595974514562460557238682286687149318259942294641573361094550974500209572943354306503601562716495913896901228050771570714968637106631217791621012659597909909050478526027434832953184955003635814102163749146122454284067747334727830471837055561704326351369297999420671941622877518672129495588882885435647614672873761318408673871147163901095715587544013148330949324558820589031231206055418951713741724923044116496063271006546801824500055234790008293506107729917139219694824334149486253303864577333798213281862215717556304395355827589017350344944664142581881996472498187075638152671681649102437312213224150443362681739913997239690861725598045828637648710220779280756868948927935837746370637783855555800576368994739646200971336948619193994684746801219258021733200754145963507769409124110177743736740187343136205527507008496103282722169372876657445820887278256535772129143360324176031872104000224296271558971122719393952754681302252691593321851250276864579879607341769323022142489712922717066168588834755412743353748056501473438752318616987316365797986708672222815506852055321834486714774432656429730164856094562757891850240000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000}
% ..
</pre>

<hr>
<div class="navbar"><a name="#navbar_bottom"></a><table width="100%" border="0" cellspacing="0" cellpadding="2" summary="navigation bar"><tr><td><a href="overview-summary.html" target="overviewFrame">Overview</a></td><td><a href="http://www.erlang.org/"><img src="erlang.png" align="right" border="0" alt="erlang logo"></a></td></tr></table></div>
<p><i>Generated by EDoc, Apr 3 2015, 18:23:58.</i></p>
<p><i>Generated by EDoc, Apr 3 2015, 19:06:07.</i></p>
</body>
</html>
23 changes: 23 additions & 0 deletions doc/overview.edoc
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,26 @@
@version 1.0.0
@title taskforce
@doc `taskforce' allows you to parallelise arbitrary tasks in a controlled way.

<hr/>
<pre lang="erlang">
application:ensure_all_started(taskforce).
IndividualTimeoutT = 100. % in miliseconds
GlobalTimeoutT = 3000. % in miliseconds
MinionCount = 4. % 4 workers

% dirty factorial
FactFun = fun(N) -&gt; lists:foldl(fun erlang:'*'/2, 1, lists:seq(1, N)) end.

Tasks = [taskforce:new_task({fact, V}, FactFun, [V], IndividualTimeoutT)
|| V &lt;- lists:seq(1, 3000)].

{ResultsById, Individualtimeouts, GlobalTimeouts} = taskforce:execute_tasks(
Tasks, GlobalTimeoutT, MinionCount).

rp(ResultsById).
% ...
% {{fact,1612},
% 155786735261829320722603634295521850549712997645292036744792078980324992080829520333637579356940021229269734555860899020135935926348738260274025884311572034997502605793835116829517075042962020336842294623372114891550621741227961590670666503556615927286307669915307416781170961816011223693599198638158655601788154923003840306479922838700449825023318474541364073269283779463774974414341010643656346570408165667718001801057557149978132222908297075885771757780095581512503464731797682668265258265660033705560137062630226988053365643176778660826718671905541604970208092965866447134353417940319949313631213418079923067731991247257565003936414027524677043363017709934421867473421824438557653800903487098193417728043085612330645749156333383094345942266405423161221384714043609762828612806439669557254921883510897202624326149505953723642369064760919035687971795152264873362873341172714124628456144001984158991169373814466854781378836145324880791973886445283088579468775740929096645785616509544620890014365718395103272508063613141021009561849132148833497958498746715377680174883841777868749956245365383672522150677505564924004272980732609677036258786106944724532240639032902765783012900038587266385478002824145754422068108960323019713831513444101234041802892228532816797657720926218423933730780350318726561535712112646101044056582512608050716659579654240107655808676572293137600978542619651764177786082298667859791086005189412815457018510480877257963423562294439181061021155376466976732753114963089332658724570646571055545272353241666937188632628395983960802397614646382421090184827994732170015852514960263477734819739200271890932190194311426485039632544473234467451553124963152777480300656435286758368532645873608039146657288143290407620370093032093894974172271758864765979271530423288675474843653206752360747492550764034045917458369942729127483700638440421528536777404252831531346640088799958284331751827312657788316769661423896076012065471265472058321414768616712810793034641372873954152609654868006802603434297632765213528539535025132242584167078933571199854441766483289562636899447940956794113921340642845225938053652169926606498830928233716980297848677063008987462525104449173729557044858854290490172514650470850123628065863293538225424918086009262264821551979623171942010654317124852444325459732757440705035563219508430063332214856568561868339321308800341439020004467957410782984558870622838281320427575133423019240832985601140874882499505916780782995915377541400684895549385699982884633908616509397791052013057818090452468856114596220701373810345870197956575569369624949383234581917806852109214734031570338687626620789115972282262266588639905682492048134486287350479594403557965173352464645386479799910791544458710480062498725166089182508941863659724832737999983336341975140830182438441212034848007541015778680281841336819262463744814566392548102016693561742311481764786375569180037790875480111272339425796827332210895445034463256919770842391765105629113558312595974514562460557238682286687149318259942294641573361094550974500209572943354306503601562716495913896901228050771570714968637106631217791621012659597909909050478526027434832953184955003635814102163749146122454284067747334727830471837055561704326351369297999420671941622877518672129495588882885435647614672873761318408673871147163901095715587544013148330949324558820589031231206055418951713741724923044116496063271006546801824500055234790008293506107729917139219694824334149486253303864577333798213281862215717556304395355827589017350344944664142581881996472498187075638152671681649102437312213224150443362681739913997239690861725598045828637648710220779280756868948927935837746370637783855555800576368994739646200971336948619193994684746801219258021733200754145963507769409124110177743736740187343136205527507008496103282722169372876657445820887278256535772129143360324176031872104000224296271558971122719393952754681302252691593321851250276864579879607341769323022142489712922717066168588834755412743353748056501473438752318616987316365797986708672222815506852055321834486714774432656429730164856094562757891850240000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000}
% ..
</pre>
2 changes: 1 addition & 1 deletion doc/packages-frame.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Application: taskforce</title>
<title>Overview</title>
<link rel="stylesheet" type="text/css" href="stylesheet.css" title="EDoc">
</head>
<body bgcolor="white">
Expand Down
2 changes: 1 addition & 1 deletion doc/taskforce.html
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,6 @@ <h3 class="function"><a name="new_task-4">new_task/4</a></h3>
<hr>

<div class="navbar"><a name="#navbar_bottom"></a><table width="100%" border="0" cellspacing="0" cellpadding="2" summary="navigation bar"><tr><td><a href="overview-summary.html" target="overviewFrame">Overview</a></td><td><a href="http://www.erlang.org/"><img src="erlang.png" align="right" border="0" alt="erlang logo"></a></td></tr></table></div>
<p><i>Generated by EDoc, Apr 3 2015, 18:23:58.</i></p>
<p><i>Generated by EDoc, Apr 3 2015, 19:06:07.</i></p>
</body>
</html>
2 changes: 1 addition & 1 deletion doc/taskforce_app.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ <h1>Module taskforce_app</h1>
<hr>

<div class="navbar"><a name="#navbar_bottom"></a><table width="100%" border="0" cellspacing="0" cellpadding="2" summary="navigation bar"><tr><td><a href="overview-summary.html" target="overviewFrame">Overview</a></td><td><a href="http://www.erlang.org/"><img src="erlang.png" align="right" border="0" alt="erlang logo"></a></td></tr></table></div>
<p><i>Generated by EDoc, Apr 3 2015, 18:23:58.</i></p>
<p><i>Generated by EDoc, Apr 3 2015, 19:06:07.</i></p>
</body>
</html>
2 changes: 1 addition & 1 deletion doc/taskforce_sup.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@ <h3 class="function"><a name="start_link-0">start_link/0</a></h3>
<hr>

<div class="navbar"><a name="#navbar_bottom"></a><table width="100%" border="0" cellspacing="0" cellpadding="2" summary="navigation bar"><tr><td><a href="overview-summary.html" target="overviewFrame">Overview</a></td><td><a href="http://www.erlang.org/"><img src="erlang.png" align="right" border="0" alt="erlang logo"></a></td></tr></table></div>
<p><i>Generated by EDoc, Apr 3 2015, 18:23:58.</i></p>
<p><i>Generated by EDoc, Apr 3 2015, 19:06:07.</i></p>
</body>
</html>
2 changes: 1 addition & 1 deletion doc/tf_master_serv.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@ <h3 class="function"><a name="start_link-2">start_link/2</a></h3>
<hr>

<div class="navbar"><a name="#navbar_bottom"></a><table width="100%" border="0" cellspacing="0" cellpadding="2" summary="navigation bar"><tr><td><a href="overview-summary.html" target="overviewFrame">Overview</a></td><td><a href="http://www.erlang.org/"><img src="erlang.png" align="right" border="0" alt="erlang logo"></a></td></tr></table></div>
<p><i>Generated by EDoc, Apr 3 2015, 18:23:58.</i></p>
<p><i>Generated by EDoc, Apr 3 2015, 19:06:07.</i></p>
</body>
</html>
2 changes: 1 addition & 1 deletion doc/tf_master_sup.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@ <h3 class="function"><a name="start_link-0">start_link/0</a></h3>
<hr>

<div class="navbar"><a name="#navbar_bottom"></a><table width="100%" border="0" cellspacing="0" cellpadding="2" summary="navigation bar"><tr><td><a href="overview-summary.html" target="overviewFrame">Overview</a></td><td><a href="http://www.erlang.org/"><img src="erlang.png" align="right" border="0" alt="erlang logo"></a></td></tr></table></div>
<p><i>Generated by EDoc, Apr 3 2015, 18:23:58.</i></p>
<p><i>Generated by EDoc, Apr 3 2015, 19:06:07.</i></p>
</body>
</html>
Loading

0 comments on commit d6a170e

Please sign in to comment.