Last active
December 15, 2015 17:20
-
-
Save meklarian/5296095 to your computer and use it in GitHub Desktop.
ad hoc parallel lambdas
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| namespace Namespace | |
| { | |
| public static class Foo | |
| { | |
| public static void Parallel(params Action[] bars) | |
| { | |
| bars.AsParallel().ForAll((a) => { if (null != a) { a(); } }); | |
| System.Threading.Thread.MemoryBarrier(); | |
| } | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // syntactic sugar, lets you do arbitrary bits in parallel | |
| Foo.Parallel( | |
| ()=>{someWorkHere();}, | |
| ()=>{someWorkThere();}, | |
| ()=>{everyWhereWorkBlahBlah();} | |
| ); | |
| // which is really nice with closures. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment