Проясните, пожалуйста. "Жарим" процессор или я чего-то не понял?
...\Microsoft Visual Studio 14.0\VC\crt\src\stl\primitives.h
class stl_critical_section_vista final : public stl_critical_section_interface
{
public:
stl_critical_section_vista()
{
__crtInitializeCriticalSectionEx(&_M_critical_section, 4000, 0);
}
...
virtual bool try_lock() override
{
return TryEnterCriticalSection(&_M_critical_section) != 0;
}
virtual bool try_lock_for(unsigned int) override
{
// STL will call try_lock_for once again if this call will not succeed
return stl_critical_section_vista::try_lock();
}
...
private:
CRITICAL_SECTION _M_critical_section;
};
class stl_critical_section_win7 final : public stl_critical_section_interface
{
public:
...
virtual bool try_lock() override
{
return __crtTryAcquireSRWLockExclusive(&m_srw_lock) != 0;
}
virtual bool try_lock_for(unsigned int) override
{
// STL will call try_lock_for once again if this call will not succeed
return stl_critical_section_win7::try_lock();
}
...
private:
SRWLOCK m_srw_lock;
};
...\Microsoft Visual Studio 14.0\VC\crt\src\stl\mutex.c
static int mtx_do_lock(_Mtx_t mtx, const xtime *target)
{
...
/* check timeout */
xtime now;
xtime_get(&now, TIME_UTC);
while (now.sec < target->sec
|| now.sec == target->sec && now.nsec < target->nsec)
{ /* time has not expired */
if (mtx->thread_id == static_cast<long>(GetCurrentThreadId())
|| mtx->_get_cs()->try_lock_for(_Xtime_diff_to_millis2(target, &now)))
{ /* stop waiting */
res = WAIT_OBJECT_0;
break;
}
else
res = WAIT_TIMEOUT;
xtime_get(&now, TIME_UTC);
}
...
}
Всё. Сам понял. Вопрос снимается.