Ticket #4885: boost thread ticket4885.patch
File boost thread ticket4885.patch, 2.4 KB (added by , 11 years ago) |
---|
-
thread.cpp
10 10 #include <boost/thread/thread.hpp> 11 11 #include <algorithm> 12 12 #ifndef UNDER_CE 13 #include <process.h> 13 # include <process.h> 14 /* Several CE SDKs don't define this constant, and some only define it in 15 kfuncs.h. Just define it here if it wasn't defined before. */ 16 # ifndef TLS_OUT_OF_INDEXES 17 # define TLS_OUT_OF_INDEXES ((DWORD)0xFFFFFFFF) 18 # endif 14 19 #endif 15 20 #include <stdio.h> 16 21 #include <boost/thread/once.hpp> … … 27 32 namespace 28 33 { 29 34 boost::once_flag current_thread_tls_init_flag=BOOST_ONCE_INIT; 30 #if defined(UNDER_CE) 31 // Windows CE does not define the TLS_OUT_OF_INDEXES constant. 32 DWORD tls_out_of_index=0xFFFFFFFF; 33 #else 34 DWORD tls_out_of_index=TLS_OUT_OF_INDEXES; 35 #endif 36 DWORD current_thread_tls_key=tls_out_of_index; 35 DWORD current_thread_tls_key=TLS_OUT_OF_INDEXES; 37 36 38 37 void create_current_thread_tls_key() 39 38 { 40 39 tss_cleanup_implemented(); // if anyone uses TSS, we need the cleanup linked in 41 40 current_thread_tls_key=TlsAlloc(); 42 BOOST_ASSERT(current_thread_tls_key!= tls_out_of_index);41 BOOST_ASSERT(current_thread_tls_key!=TLS_OUT_OF_INDEXES); 43 42 } 44 43 45 44 void cleanup_tls_key() 46 45 { 47 if(current_thread_tls_key!= tls_out_of_index)46 if(current_thread_tls_key!=TLS_OUT_OF_INDEXES) 48 47 { 49 48 TlsFree(current_thread_tls_key); 50 current_thread_tls_key= tls_out_of_index;49 current_thread_tls_key=TLS_OUT_OF_INDEXES; 51 50 } 52 51 } 53 52 54 53 detail::thread_data_base* get_current_thread_data() 55 54 { 56 if(current_thread_tls_key== tls_out_of_index)55 if(current_thread_tls_key==TLS_OUT_OF_INDEXES) 57 56 { 58 57 return 0; 59 58 } … … 63 62 void set_current_thread_data(detail::thread_data_base* new_data) 64 63 { 65 64 boost::call_once(current_thread_tls_init_flag,create_current_thread_tls_key); 66 if(current_thread_tls_key!= tls_out_of_index)65 if(current_thread_tls_key!=TLS_OUT_OF_INDEXES) 67 66 BOOST_VERIFY(TlsSetValue(current_thread_tls_key,new_data)); 68 67 else 69 68 boost::throw_exception(thread_resource_error());