Std :: mutex :: Windows lock error, error code 3

I use std::mutex and std::lock_guard in the correct RAII form throughout the application:

 struct Foo { int f() const { std::lock_guard<std::mutex> locker(m_mutex); return m_i; } private: int m_i = 0; mutable std::mutex m_mutex; }; 

It always worked, but I added another class to parallelism, and in this new class locker throws std::system_error . The problem here ( xthread header):

 inline int _Mtx_lockX(_Mtx_t *_Mtx) { // throw exception on failure return (_Check_C_return(_Mtx_lock(_Mtx))); } 

_Mtx_lock returns 3, and the expected value is 0. I do not know what 3 means.

VS2013, v120_x64.

+7
c ++ multithreading windows mutex c ++ 11
source share
1 answer

The error indicated by @ Phantom (_Thrd_busy) implies that the lock was recursively accepted. Also see this answer

+6
source share

All Articles