DynamoDS/Dynamo — pull request #2875 by Benglin (2014-10-28 09:54:06+00:00)
Title: Scheduler enhancement: task parallelism (DNM)

Background
-----
This pull request enables ```AsyncTask``` parallelism support in ```DynamoScheduler```. It builds on top of [a previous pull request](https://github.com/DynamoDS/Dynamo/pull/2848) to enable task parallelism. A new property ```AsyncTask.Parallelizable``` is exposed to allow a specific ```AsyncTask``` type to be executed in parallel alongside other ```AsyncTask```.

Changes
-----
The following changes are included in this pull request:

- ```AsyncTask.Parallelizable``` abstract property is introduced to indicate that a given ```AsyncTask``` can be executed in parallel.

- ```DynamoScheduler.EnableTaskParallelization``` property is introduced to disable task parallelism during runtime. This is desirable for test cases which expect precise results to be produced.

- Task parallelism is accomplished with ```Parallel.ForEach``` statement. This statement is invoked on the context of ```ISchedulerThread``` but the actual ```AsyncTask.Execute``` method is executed in parallel on different set of threads. ```ISchedulerThread``` blocks on these parallel threads and will only resume when ```Parallel.ForEach``` returns.

- Currently only ```UpdateRenderPackageAsyncTask``` is being executed in parallel. Its ```ExecuteCore``` method calls on ```IGraphicItem.Tessellate``` method to perform tessellation in parallel. According to ASM documentation, these faceting methods do not modify the underlying objects and are thread safe.

Testing scenario
-----
I'm going to try things out on both standalone and Revit hosted scenarios. Report back shortly.

Notes to reviewer
-----
Hi @lukechurch @ikeough, this is where things start to get interesting.