Guest User

Untitled

a guest
Jul 18th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. pub struct Threadable<J> where J:Clone{
  2. slowdown_signal: Arc<AtomicBool>,
  3. semaphore: Arc<Semaphore>,
  4. termination_signal: Lockstep<Option<String>>,
  5. time: Lockstep<SystemTime>,
  6. readonly_data: Arc<J>
  7. }
  8.  
  9. impl<J> Threadable<J> {
  10. pub fn create(starting_th: isize, max_th: isize, data: J) -> Threadable<J> {
  11. let slowdown = AtomicBool::new(false);
  12. let slowdown_signal: Arc<AtomicBool> = Arc::new(slowdown);
  13. let semaphore: Arc<Semaphore> = prepare_semaphore(starting_th, max_th);
  14. let termination_signal: Lockstep<Option<String>> = Arc::new(Mutex::new(None));
  15. let time: Lockstep<SystemTime> = Arc::new(Mutex::new(SystemTime::now()));
  16. let data = Arc::new(data);
  17. Threadable{slowdown_signal: slowdown_signal, semaphore:semaphore,
  18. termination_signal: termination_signal, time: time, readonly_data: data}
  19. }
  20.  
  21. pub fn clone(&self) -> Threadable<J> {
  22. ...
  23. }
  24. ...
  25. }
Add Comment
Please, Sign In to add comment