@@ -286,28 +286,6 @@ impl<T> Worker<T> {
286286 }
287287 }
288288
289- /// Checks if the worker and the provided stealer are pointing to the same underlying queue.
290- ///
291- /// # Examples
292- ///
293- /// ```
294- /// use crossbeam_deque::Worker;
295- ///
296- /// let w_1 = Worker::<i32>::new_lifo();
297- /// let w_2 = Worker::<i32>::new_fifo();
298- ///
299- /// let s_1 = w_1.stealer();
300- /// let s_2 = w_2.stealer();
301- ///
302- /// assert!(w_1.donates_to(&s_1));
303- /// assert!(w_2.donates_to(&s_2));
304- /// assert!(!w_1.donates_to(&s_2));
305- /// assert!(!w_2.donates_to(&s_1));
306- /// ```
307- pub fn donates_to ( & self , stealer : & Stealer < T > ) -> bool {
308- Arc :: ptr_eq ( & self . inner , & stealer. inner )
309- }
310-
311289 /// Resizes the internal buffer to the new capacity of `new_cap`.
312290 #[ cold]
313291 unsafe fn resize ( & self , new_cap : usize ) {
@@ -645,6 +623,30 @@ impl<T> Stealer<T> {
645623 b. wrapping_sub ( f) . max ( 0 ) as usize
646624 }
647625
626+ /// Checks if the stealer will steal from the provided worker.
627+ ///
628+ /// If both are pointing to the same underlying queue, this will return false.
629+ ///
630+ /// # Examples
631+ ///
632+ /// ```
633+ /// use crossbeam_deque::Worker;
634+ ///
635+ /// let w_1 = Worker::<i32>::new_lifo();
636+ /// let w_2 = Worker::<i32>::new_fifo();
637+ ///
638+ /// let s_1 = w_1.stealer();
639+ /// let s_2 = w_2.stealer();
640+ ///
641+ /// assert!(!w_1.will_steal_fromq(&s_1));
642+ /// assert!(!w_2.will_steal_fromq(&s_2));
643+ /// assert!(w_1.will_steal_fromq(&s_2));
644+ /// assert!(w_2.will_steal_fromq(&s_1));
645+ /// ```
646+ pub fn will_steal_fromq ( & self , stealer : & Stealer < T > ) -> bool {
647+ !Arc :: ptr_eq ( & self . inner , & stealer. inner )
648+ }
649+
648650 /// Steals a task from the queue.
649651 ///
650652 /// # Examples
0 commit comments