SHARE
TWEET

Untitled

a guest Jun 18th, 2019 59 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. pub struct Queue
  2. {
  3.     data: std::collections::VecDeque<u8>,
  4. }
  5.  
  6. impl Queue
  7. {
  8.     pub fn push(&mut self, val: u8)
  9.     {
  10.         self.data.push_back(val);
  11.     }
  12.  
  13.     pub fn pop(&mut self)
  14.     {
  15.         if !self.data.is_empty()
  16.         {
  17.             self.data.pop_front();
  18.         }
  19.     }
  20.  
  21.     pub fn front(&self) -> u8
  22.     {
  23.         *self.data.front().unwrap()
  24.     }
  25. }
  26.      
  27. fn processing(i_b: &mut Arc<RefCell<Queue>>, o_b: &mut Arc<RefCell<Queue>>)
  28.     {
  29.         i_b.get_mut().pop();
  30.         print!("{}, {} : ", i_b.get_mut().front(), o_b.get_mut().front());
  31.     }
  32.      
  33. error[E0277]: `std::cell::RefCell<Queue>` cannot be shared between threads safely
  34.   --> srcmain.rs:69:14
  35.    |
  36. 69 |     let _c = thread::spawn(move || {
  37.    |              ^^^^^^^^^^^^^ `std::cell::RefCell<Queue>` cannot be shared between threads safely
  38.    |
  39.    = help: the trait `std::marker::Sync` is not implemented for `std::cell::RefCell<Queue>`
  40.    = note: required because of the requirements on the impl of `std::marker::Send` for `std::sync::Arc<std::cell::RefCell<Queue>>`
  41.    = note: required because it appears within the type `[closure@srcmain.rs:69:28: 71:6 _a:std::sync::Arc<std::cell::RefCell<Queue>>, _b:std::sync::Arc<std::cell::RefCell<Queue>>]`
  42.    = note: required by `std::thread::spawn`
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top