Click or drag to resize
DigitalRuneMultithreading

This section describes how to configure multithreading in DigitalRune Physics.

Multithreading in DigitalRune Physics

A physics simulation has integrated support for multithreading to automatically distribute the workload across multiple CPU cores.

A Simulation contains a CollisionDomain that detects collision between objects. The collision detection can be configure to run in parallel by setting the property CollisionDomainEnableMultithreading. See also: Multithreading in DigitalRune Geometry

The physics simulation can also be configured to run in parallel by setting the property SimulationSettingsEnableMultithreading in the Settings. When multithreading is enabled all updates and simulations islands are solved in parallel.

Multithreading is enabled by default on systems with multiple CPU cores (typical PCs and the Xbox 360). You need to disable these two properties if you decide to run the collision detection and physics simulation 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.

Caution note Caution

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.

See Also