@@ -669,9 +669,11 @@ impl Device {
669669 /// Note that a `false` result here does *not* guarantee that no further activity will
670670 /// occur on the `Device`. A [`Device`] can be marked invalid at any time, even while
671671 /// locks are held, meaning that operations begun before the `Device` was marked
672- /// invalid will still generally run to completion. This is simply a consequence of
673- /// making [`Device::valid`] an `AtomicBool`, rather than an ordinary `bool` field
674- /// protected by the same locks that all other operations acquire.
672+ /// invalid will still generally run to completion. This is a consequence of
673+ /// making [`Device::valid`] an `AtomicBool`. It could be avoided by making
674+ /// [`Device::valid`] an ordinary `bool` field protected by the same locks that
675+ /// all other operations acquire, but we use an `AtomicBool` because there
676+ /// are many device validity checks and we want those to be cheap.
675677 pub fn is_valid ( & self ) -> bool {
676678 self . valid . load ( Ordering :: Acquire )
677679 }
@@ -916,7 +918,7 @@ impl Device {
916918 // However, checking device validity for this purpose is tricky. A device can be
917919 // marked invalid at any time, regardless of what locks are held. This means that,
918920 // even though queue submission does check device validity at the start (in
919- // `Queue::allocate_submission`), the submission will proceed even if the the
921+ // `Queue::allocate_submission`), the submission will proceed even if the
920922 // device gets marked invalid after that check. Thus, other threads can observe
921923 // the queue becoming non-empty even after they have observed the device to be
922924 // invalid.
0 commit comments