File tree Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -284,6 +284,28 @@ impl<T> Worker<T> {
284284 }
285285 }
286286
287+ /// Checks if the worker and the provided stealer are pointing to the same underlying queue.
288+ ///
289+ /// # Examples
290+ ///
291+ /// ```
292+ /// use crossbeam_deque::Worker;
293+ ///
294+ /// let w_1 = Worker::<i32>::new_lifo();
295+ /// let w_2 = Worker::<i32>::new_fifo();
296+ ///
297+ /// let s_1 = w.stealer();
298+ /// let s_2 = w.stealer();
299+ ///
300+ /// assert!(w_1.is_same_as(&s_1));
301+ /// assert!(w_2.is_same_as(&s_2));
302+ /// assert!(!w_1.is_same_as(&s_2));
303+ /// assert!(!w_2.is_same_as(&s_1));
304+ /// ```
305+ pub fn is_same_as ( & self , stealer : & Stealer < T > ) -> bool {
306+ Arc :: ptr_eq ( & self . inner , & stealer. inner )
307+ }
308+
287309 /// Resizes the internal buffer to the new capacity of `new_cap`.
288310 #[ cold]
289311 unsafe fn resize ( & self , new_cap : usize ) {
You can’t perform that action at this time.
0 commit comments