This section describes how to configure multithreading in DigitalRune Geometry.
Multithreading in DigitalRune Geometry
All collision algorithms implemented in DigitalRune Geometry are thread-safe. Collision queries between any objects using any of the available collision algorithms can be performed concurrently on multiple threads and even recursively.
A CollisionDomain has integrated support for multithreading. Multithreading can be enabled by setting the property CollisionDomain..::..EnableMultithreading. In multithreading mode collision queries are automatically computed in parallel on multiple threads.
The property is enabled by default on systems with multiple CPU cores (typical PCs and the Xbox 360). You need to disable multithreading if you decide to run the collision detection on a single thread.
The multithreading support is provided by the DigitalRune Base Library. The namespace DigitalRune.Threading provides a task-based threading library that works cross-platform. The solution is highly optimized for the .NET Compact Framework to achieve maximum performance on the Xbox 360.
The DigitalRune libraries make extensive use of this threading library. You should take advantage of the library if you plan to implement concurrency in your application. The threading solution is fully configurable and the included task scheduler can automatically balance the workload across all available CPU cores. See class Parallel to find out more.
It is not recommended to use multiple threading solutions in one application. Using multiple independent solutions can lead to bad load balancing and oversubscription. The additional overhead can cause a performance hit.