fix failing doc test and clear up docs (#6314)
# Objective Fixes https://github.com/bevyengine/bevy/issues/6306 ## Solution Change the failing assert and expand example to explain when ordering is deterministic or not. Co-authored-by: Mike Hsu <mike.hsu@gmail.com>
This commit is contained in:
		
							parent
							
								
									abbc0cf339
								
							
						
					
					
						commit
						48e9dc1964
					
				@ -164,11 +164,19 @@ impl TaskPool {
 | 
				
			|||||||
    ///     });
 | 
					    ///     });
 | 
				
			||||||
    /// });
 | 
					    /// });
 | 
				
			||||||
    ///
 | 
					    ///
 | 
				
			||||||
    /// // results are returned in the order the tasks are spawned in.
 | 
					    /// // The ordering of results is non-deterministic if you spawn from within tasks as above.
 | 
				
			||||||
    /// // Note: the ordering may become non-deterministic if you spawn from within tasks.
 | 
					    /// // If you're doing this, you'll have to write your code to not depend on the ordering.
 | 
				
			||||||
    /// // the ordering is only guaranteed when tasks are spawned directly from the main closure.
 | 
					    /// assert!(results.contains(&0));
 | 
				
			||||||
 | 
					    /// assert!(results.contains(&1));
 | 
				
			||||||
 | 
					    ///
 | 
				
			||||||
 | 
					    /// // The ordering is deterministic if you only spawn directly from the closure function.
 | 
				
			||||||
 | 
					    /// let results = pool.scope(|s| {
 | 
				
			||||||
 | 
					    ///     s.spawn(async { 0  });
 | 
				
			||||||
 | 
					    ///     s.spawn(async { 1 });
 | 
				
			||||||
 | 
					    /// });
 | 
				
			||||||
    /// assert_eq!(&results[..], &[0, 1]);
 | 
					    /// assert_eq!(&results[..], &[0, 1]);
 | 
				
			||||||
    /// // can access x after scope runs
 | 
					    ///
 | 
				
			||||||
 | 
					    /// // You can access x after scope runs, since it was only temporarily borrowed in the scope.
 | 
				
			||||||
    /// assert_eq!(x, 2);
 | 
					    /// assert_eq!(x, 2);
 | 
				
			||||||
    /// ```
 | 
					    /// ```
 | 
				
			||||||
    ///
 | 
					    ///
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user