mutex destroy while busy

The cause of the problem is that the lock is destroyed during busy. The possible problem is that after the mutex executes the lock and is not unlocked, something goes wrong. For example,

   void fun() {
        mutex m;
        int a = 1;
        m.lock();
        if (a > 0) {
            return;
        }
        m.unlock();
    }

If m is not unlocked and the locked memory is destroyed, an error will occur!

Guess you like

Origin blog.csdn.net/Theflowerofac/article/details/101317646