OGWWorldSimulation Class Reference
Inherits from | NSObject |
Declared in | OGWWorldSimulation.h |
Overview
Updates entities and their aspects in the order their categories were added to the OGWWorld.
Concurrency
If a OGWEntityCategory allows concurrent updates the simulation will update the entities of that category asynchronously via Grand Central Dispatch - only on multi-core CPUs. On single-core CPUs GCD is not used to avoid the (then unnecessary) overhead of GCD.
Warning: Concurrent updates can lead to a host of undesirable side-effects. In concurrent updates the order in which entities are updated is no longer guaranteed. Thus entities of the same category depending on or influencing each other may sometimes lag one frame behind the other, which may result in anything from a hardly noticable visual glitch to unrecoverable bugs. The more autonomous entities of a category are the more likely you can update them concurrently. To test whether a specific issue may be caused by concurrent updates, try setting disableConcurrentUpdates to YES.
Tasks
Stepping
-
currentStep
property -
performingStep
property -
disableConcurrentUpdates
property
Concurrency
-
numLogicalCPUs
property -
numPhysicalCPUs
property
Internal Use Only
Properties
currentStep
The simulation step counts the number of times the world simulation was performed.
@property (readonly) GWStep currentStep
Return Value
The current simulation step.
Discussion
Before the first call to [world simulate] the value is 0 and the first step starts with 1.
See Also
Declared In
OGWWorldSimulation.h
disableConcurrentUpdates
In some situations or just for testing (ruling out concurrency bugs) or benchmarking you may want to disable concurrent updates. If concurrent updates are disabled, entities in all categories will be updated sequentially in the order they were added, regardless of their OGWEntityCategory’s updateConcurrently property.
@property BOOL disableConcurrentUpdates
Return Value
Whether concurrent updates are disabled.
Declared In
OGWWorldSimulation.h
numLogicalCPUs
Number of logical CPUs, which is the aggregate of both physical and logical cores (ie Core i7 with hyperthreading has 8 logical cores: 4 physical + 4 hyperthreaded). On single-core CPUs it is preferable to avoid the overhead of multithreaded code. Use this value to determine whether to run a section of code concurrently or not.
@property (readonly) uint16_t numLogicalCPUs
Return Value
1 (one) if the current hardware has a single-core CPU. Otherwise returns the number of cores, including virtual (hyperthreading) cores.
See Also
Declared In
OGWWorldSimulation.h
numPhysicalCPUs
This returns the number of actual physical cores, excluding any virtual (hyperthreading) cores. If logical cores is greater than physical cores, the CPU has a hyperthreading or similar “virtual cores” technology.
@property (readonly) uint16_t numPhysicalCPUs
Return Value
1 (one) if the current hardware has a single-core CPU. Otherwise returns the number of physical cores.
See Also
Declared In
OGWWorldSimulation.h