Advertisement
Hemirt

Untitled

Nov 23rd, 2016
244
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.36 KB | None | 0 0
  1. class 4HEad
  2. {
  3.     void stuff();
  4.     ~4HEad();
  5.     bool quit = false;
  6.     std::mutex mtx;
  7. };
  8.  
  9. void stuff()
  10. {
  11.     while(!quit)
  12.     {
  13.         mtx.lock()
  14.         read();
  15.         do_sth_with_the_data();
  16.         mtx.unlock();  
  17.     }
  18. }
  19.  
  20. 4HEad::~4HEad()
  21. {
  22.     quit = true;
  23.     abort_read();
  24.     mtx.lock();
  25.     destroy_stuff();
  26. }
  27.  
  28. int main()
  29. {
  30.     4HEad *obj = new 4HEad;
  31.     //wait for signal
  32.     delete obj;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement