зеркало из https://github.com/microsoft/STL.git
Cleanups: Simplify `thread` and `condition_variable`, identify unused dllexports (#3532)
This commit is contained in:
Родитель
1e066dc1b7
Коммит
f2633d382b
|
@ -224,16 +224,8 @@ public:
|
||||||
// but unfortunately our ABI speaks struct xtime, which is relative to the system clock.
|
// but unfortunately our ABI speaks struct xtime, which is relative to the system clock.
|
||||||
_CSTD xtime _Tgt;
|
_CSTD xtime _Tgt;
|
||||||
(void) _To_xtime_10_day_clamped(_Tgt, _Rel_time);
|
(void) _To_xtime_10_day_clamped(_Tgt, _Rel_time);
|
||||||
const int _Res = _Cnd_timedwait(_Mycnd(), _Myptr->_Mymtx(), &_Tgt);
|
(void) _Cnd_timedwait(_Mycnd(), _Myptr->_Mymtx(), &_Tgt);
|
||||||
_Guard_unlocks_before_locking_outer.unlock();
|
_Guard_unlocks_before_locking_outer.unlock();
|
||||||
|
|
||||||
switch (_Res) {
|
|
||||||
case _Thrd_timedout:
|
|
||||||
case _Thrd_success:
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
_Throw_C_error(_Res);
|
|
||||||
}
|
|
||||||
} // relock
|
} // relock
|
||||||
|
|
||||||
return _Pred();
|
return _Pred();
|
||||||
|
@ -262,13 +254,10 @@ private:
|
||||||
const int _Res = _Cnd_timedwait(_Mycnd(), _Ptr->_Mymtx(), _Abs_time);
|
const int _Res = _Cnd_timedwait(_Mycnd(), _Ptr->_Mymtx(), _Abs_time);
|
||||||
_Guard.unlock();
|
_Guard.unlock();
|
||||||
|
|
||||||
switch (_Res) {
|
if (_Res == _Thrd_success) {
|
||||||
case _Thrd_success:
|
|
||||||
return cv_status::no_timeout;
|
return cv_status::no_timeout;
|
||||||
case _Thrd_timedout:
|
} else {
|
||||||
return cv_status::timeout;
|
return cv_status::timeout;
|
||||||
default:
|
|
||||||
_Throw_C_error(_Res);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -746,13 +746,11 @@ public:
|
||||||
|
|
||||||
// Nothing to do to comply with LWG-2135 because std::mutex lock/unlock are nothrow
|
// Nothing to do to comply with LWG-2135 because std::mutex lock/unlock are nothrow
|
||||||
const int _Res = _Cnd_timedwait(_Mycnd(), _Lck.mutex()->_Mymtx(), _Abs_time);
|
const int _Res = _Cnd_timedwait(_Mycnd(), _Lck.mutex()->_Mymtx(), _Abs_time);
|
||||||
switch (_Res) {
|
|
||||||
case _Thrd_success:
|
if (_Res == _Thrd_success) {
|
||||||
return cv_status::no_timeout;
|
return cv_status::no_timeout;
|
||||||
case _Thrd_timedout:
|
} else {
|
||||||
return cv_status::timeout;
|
return cv_status::timeout;
|
||||||
default:
|
|
||||||
_Throw_C_error(_Res);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -137,7 +137,10 @@ public:
|
||||||
_Throw_Cpp_error(_INVALID_ARGUMENT);
|
_Throw_Cpp_error(_INVALID_ARGUMENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
_Check_C_return(_Thrd_detach(_Thr));
|
if (_Thrd_detach(_Thr) != _Thrd_success) {
|
||||||
|
_Throw_Cpp_error(_INVALID_ARGUMENT);
|
||||||
|
}
|
||||||
|
|
||||||
_Thr = {};
|
_Thr = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -129,16 +129,7 @@ enum { // constants for error codes
|
||||||
_RESOURCE_UNAVAILABLE_TRY_AGAIN
|
_RESOURCE_UNAVAILABLE_TRY_AGAIN
|
||||||
};
|
};
|
||||||
|
|
||||||
extern "C++" [[noreturn]] _CRTIMP2_PURE void __cdecl _Throw_C_error(int _Code);
|
|
||||||
extern "C++" [[noreturn]] _CRTIMP2_PURE void __cdecl _Throw_Cpp_error(int _Code);
|
extern "C++" [[noreturn]] _CRTIMP2_PURE void __cdecl _Throw_Cpp_error(int _Code);
|
||||||
|
|
||||||
inline int _Check_C_return(int _Res) { // throw exception on failure
|
|
||||||
if (_Res != _Thrd_success) {
|
|
||||||
_Throw_C_error(_Res);
|
|
||||||
}
|
|
||||||
|
|
||||||
return _Res;
|
|
||||||
}
|
|
||||||
_STD_END
|
_STD_END
|
||||||
#pragma pop_macro("new")
|
#pragma pop_macro("new")
|
||||||
_STL_RESTORE_CLANG_WARNINGS
|
_STL_RESTORE_CLANG_WARNINGS
|
||||||
|
|
|
@ -27,7 +27,6 @@ struct xtime { // store time with nanosecond resolution
|
||||||
|
|
||||||
_CRTIMP2_PURE int __cdecl xtime_get(xtime*, int);
|
_CRTIMP2_PURE int __cdecl xtime_get(xtime*, int);
|
||||||
|
|
||||||
_CRTIMP2_PURE long __cdecl _Xtime_diff_to_millis(const xtime*);
|
|
||||||
_CRTIMP2_PURE long __cdecl _Xtime_diff_to_millis2(const xtime*, const xtime*);
|
_CRTIMP2_PURE long __cdecl _Xtime_diff_to_millis2(const xtime*, const xtime*);
|
||||||
_CRTIMP2_PURE long long __cdecl _Xtime_get_ticks();
|
_CRTIMP2_PURE long long __cdecl _Xtime_get_ticks();
|
||||||
|
|
||||||
|
|
|
@ -35,6 +35,7 @@ static constexpr errc codes[] = {
|
||||||
_THROW(system_error(static_cast<int>(codes[code]), _STD generic_category(), msgs[code]));
|
_THROW(system_error(static_cast<int>(codes[code]), _STD generic_category(), msgs[code]));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TRANSITION, ABI: preserved for binary compatibility
|
||||||
[[noreturn]] _CRTIMP2_PURE void __cdecl _Throw_C_error(int code) { // throw error object for C error
|
[[noreturn]] _CRTIMP2_PURE void __cdecl _Throw_C_error(int code) { // throw error object for C error
|
||||||
switch (code) { // select the exception
|
switch (code) { // select the exception
|
||||||
case _Thrd_nomem:
|
case _Thrd_nomem:
|
||||||
|
|
|
@ -64,6 +64,7 @@ _CRTIMP2_PURE long __cdecl _Xtime_diff_to_millis2(const xtime* xt1, const xtime*
|
||||||
return static_cast<long>(diff.sec * _Msec_per_sec + (diff.nsec + _Nsec_per_msec - 1) / _Nsec_per_msec);
|
return static_cast<long>(diff.sec * _Msec_per_sec + (diff.nsec + _Nsec_per_msec - 1) / _Nsec_per_msec);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TRANSITION, ABI: preserved for binary compatibility
|
||||||
_CRTIMP2_PURE long __cdecl _Xtime_diff_to_millis(const xtime* xt) { // convert time to milliseconds
|
_CRTIMP2_PURE long __cdecl _Xtime_diff_to_millis(const xtime* xt) { // convert time to milliseconds
|
||||||
xtime now;
|
xtime now;
|
||||||
xtime_get(&now, TIME_UTC);
|
xtime_get(&now, TIME_UTC);
|
||||||
|
|
Загрузка…
Ссылка в новой задаче