Ticket #4885: 4885.patch
File 4885.patch, 2.1 KB (added by , 11 years ago) |
---|
-
thread.cpp
27 27 namespace 28 28 { 29 29 boost::once_flag current_thread_tls_init_flag=BOOST_ONCE_INIT; 30 DWORD current_thread_tls_key=0; 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; 31 37 32 38 void create_current_thread_tls_key() 33 39 { 34 40 tss_cleanup_implemented(); // if anyone uses TSS, we need the cleanup linked in 35 41 current_thread_tls_key=TlsAlloc(); 36 #if defined(UNDER_CE) 37 // Windows CE does not define the TLS_OUT_OF_INDEXES constant. 38 BOOST_ASSERT(current_thread_tls_key!=0xFFFFFFFF); 39 #else 40 BOOST_ASSERT(current_thread_tls_key!=TLS_OUT_OF_INDEXES); 41 #endif 42 BOOST_ASSERT(current_thread_tls_key!=tls_out_of_index); 42 43 } 43 44 44 45 void cleanup_tls_key() 45 46 { 46 if(current_thread_tls_key )47 if(current_thread_tls_key!=tls_out_of_index) 47 48 { 48 49 TlsFree(current_thread_tls_key); 49 current_thread_tls_key= 0;50 current_thread_tls_key=tls_out_of_index; 50 51 } 51 52 } 52 53 53 54 detail::thread_data_base* get_current_thread_data() 54 55 { 55 if( !current_thread_tls_key)56 if(current_thread_tls_key==tls_out_of_index) 56 57 { 57 58 return 0; 58 59 } … … 62 63 void set_current_thread_data(detail::thread_data_base* new_data) 63 64 { 64 65 boost::call_once(current_thread_tls_init_flag,create_current_thread_tls_key); 65 if(current_thread_tls_key )66 if(current_thread_tls_key!=tls_out_of_index) 66 67 BOOST_VERIFY(TlsSetValue(current_thread_tls_key,new_data)); 67 68 else 68 69 boost::throw_exception(thread_resource_error());