26 #ifndef _STLP_THREADS_C 27 #define _STLP_THREADS_C 29 #ifndef _STLP_INTERNAL_THREADS_H 33 #if defined (_STLP_EXPOSE_GLOBALS_IMPLEMENTATION) 35 #if defined (_STLP_SGI_THREADS) 37 #elif defined (_STLP_UNIX) 38 # ifndef _STLP_INTERNAL_CTIME 41 # if defined (_STLP_USE_NAMESPACES) && !defined (_STLP_VENDOR_GLOBAL_CSTD) 49 #if defined (_STLP_USE_ATOMIC_SWAP_MUTEX) 50 template<
int __32bits>
53 # undef _STLP_USE_ATOMIC_SWAP_MUTEX 56 #if defined (_STLP_THREADS) && !defined (_STLP_USE_PTHREAD_SPINLOCK) 62 #endif // _STLP_USE_PTHREAD_SPINLOCK 64 #if defined (_STLP_THREADS) && !defined (_STLP_USE_PTHREAD_SPINLOCK) 66 # if defined (_STLP_SPARC_SOLARIS_THREADS) 69 # define _STLP_NANOSLEEP __nanosleep 71 # define _STLP_NANOSLEEP nanosleep 76 _STLP_mutex_spin<__inst>::_S_nsec_sleep(
int __log_nsec,
unsigned int& __iteration) {
77 # if defined (_STLP_WIN32THREADS) 78 # if defined (_WIN32_WINNT) && (_WIN32_WINNT >= 0x0400) 79 if (__iteration <= 4000) {
88 if (__log_nsec <= 21) {
95 Sleep(1 << (__log_nsec - 20));
97 # if defined (_WIN32_WINNT) && (_WIN32_WINNT >= 0x0400) 101 # elif defined(_STLP_OS2THREADS) 102 if (__log_nsec <= 20) {
105 DosSleep(1 << (__log_nsec - 20));
107 # elif defined (_STLP_UNIX) 111 __ts.
tv_nsec = 1 << __log_nsec;
112 _STLP_NANOSLEEP(&__ts, 0);
116 template <
int __inst>
118 _STLP_mutex_spin<__inst>::_M_do_lock(
volatile __stl_atomic_t* __lock) {
119 # if defined(_STLP_ATOMIC_EXCHANGE) 123 volatile unsigned __junk = 17;
126 for (__i = 0; __i < __my_spin_max; ++__i) {
127 if (__i < __my_last_spins/2 || *__lock) {
128 __junk *= __junk; __junk *= __junk;
129 __junk *= __junk; __junk *= __junk;
146 for (__i = 0 ;; ++__i) {
147 int __log_nsec = __i + 6;
149 if (__log_nsec > 27) __log_nsec = 27;
153 _S_nsec_sleep(__log_nsec, __i);
158 #endif // _STLP_USE_PTHREAD_SPINLOCK
BOOL WINAPI SwitchToThread(VOID)
VOID WINAPI DECLSPEC_HOTPATCH Sleep(IN DWORD dwMilliseconds)
#define _STLP_STATIC_MUTEX
_STLP_INLINE_LOOP _InputIter __last
#define _STLP_MUTEX_INITIALIZER
#define _STLP_END_NAMESPACE
#define _STLP_BEGIN_NAMESPACE
__stl_atomic_t _STLP_CALL _Atomic_swap(_STLP_VOLATILE __stl_atomic_t *__p, __stl_atomic_t __q)