@@ -447,6 +447,8 @@ pub fn park() {
447
447
* guard = false ;
448
448
}
449
449
450
+ /// Use [park_timeout].
451
+ ///
450
452
/// Blocks unless or until the current thread's token is made available or
451
453
/// the specified duration has been reached (may wake spuriously).
452
454
///
@@ -456,7 +458,10 @@ pub fn park() {
456
458
/// preemption or platform differences that may not cause the maximum
457
459
/// amount of time waited to be precisely `ms` long.
458
460
///
459
- /// See the module doc for more detail.
461
+ /// See the [module documentation][thread] for more detail.
462
+ ///
463
+ /// [thread]: index.html
464
+ /// [park_timeout]: fn.park_timeout.html
460
465
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
461
466
#[ rustc_deprecated( since = "1.6.0" , reason = "replaced by `std::thread::park_timeout`" ) ]
462
467
pub fn park_timeout_ms ( ms : u32 ) {
@@ -478,6 +483,25 @@ pub fn park_timeout_ms(ms: u32) {
478
483
///
479
484
/// Platforms which do not support nanosecond precision for sleeping will have
480
485
/// `dur` rounded up to the nearest granularity of time they can sleep for.
486
+ ///
487
+ /// # Example
488
+ ///
489
+ /// Waiting for the complete expiration of the timeout:
490
+ ///
491
+ /// ```rust,no_run
492
+ /// use std::thread::park_timeout;
493
+ /// use std::time::{Instant, Duration};
494
+ ///
495
+ /// let timeout = Duration::from_secs(2);
496
+ /// let beginning_park = Instant::now();
497
+ /// park_timeout(timeout);
498
+ ///
499
+ /// while beginning_park.elapsed() < timeout {
500
+ /// println!("restarting park_timeout after {:?}", beginning_park.elapsed());
501
+ /// let timeout = timeout - beginning_park.elapsed();
502
+ /// park_timeout(timeout);
503
+ /// }
504
+ /// ```
481
505
#[ stable( feature = "park_timeout" , since = "1.4.0" ) ]
482
506
pub fn park_timeout ( dur : Duration ) {
483
507
let thread = current ( ) ;
0 commit comments