Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class myClass {
- public:
- myClass(ClassB * x) {
- myThread = thread(&myClass::run, this);
- classB = x;
- }
- ~myClass() { myThread.detach(); }
- void run() {
- while (something) {
- // do your work.
- }
- classB->endThisObject(this);
- }
- private:
- thread myThread;
- ClassB * classB;
- }
- ClassB {
- public:
- endThisObject(myClass * x) { delete x; }
- }
Add Comment
Please, Sign In to add comment