@@ -52,7 +52,9 @@ pub unsafe fn put<T>(sched: ~T) {
52
52
pub unsafe fn take < T > ( ) -> ~T {
53
53
let key = tls_key ( ) ;
54
54
let void_ptr: * mut c_void = tls:: get ( key) ;
55
- rtassert ! ( void_ptr. is_not_null( ) ) ;
55
+ if void_ptr. is_null ( ) {
56
+ rtabort ! ( "thread-local pointer is null. bogus!" ) ;
57
+ }
56
58
let ptr: ~T = cast:: transmute ( void_ptr) ;
57
59
tls:: set ( key, ptr:: mut_null ( ) ) ;
58
60
return ptr;
@@ -68,8 +70,8 @@ pub fn exists() -> bool {
68
70
}
69
71
}
70
72
71
- /// Borrow the thread-local scheduler from thread-local storage.
72
- /// While the scheduler is borrowed it is not available in TLS.
73
+ /// Borrow the thread-local value from thread-local storage.
74
+ /// While the value is borrowed it is not available in TLS.
73
75
///
74
76
/// # Safety note
75
77
///
@@ -88,21 +90,23 @@ pub unsafe fn borrow<T>(f: &fn(&mut T)) {
88
90
}
89
91
}
90
92
91
- /// Borrow a mutable reference to the thread-local Scheduler
93
+ /// Borrow a mutable reference to the thread-local value
92
94
///
93
95
/// # Safety Note
94
96
///
95
- /// Because this leaves the Scheduler in thread-local storage it is possible
97
+ /// Because this leaves the value in thread-local storage it is possible
96
98
/// For the Scheduler pointer to be aliased
97
99
pub unsafe fn unsafe_borrow < T > ( ) -> * mut T {
98
100
let key = tls_key ( ) ;
99
- let mut void_sched: * mut c_void = tls:: get ( key) ;
100
- rtassert ! ( void_sched. is_not_null( ) ) ;
101
+ let mut void_ptr: * mut c_void = tls:: get ( key) ;
102
+ if void_ptr. is_null ( ) {
103
+ rtabort ! ( "thread-local pointer is null. bogus!" ) ;
104
+ }
101
105
{
102
- let sched : * mut * mut c_void = & mut void_sched ;
103
- let sched : * mut ~T = sched as * mut ~T ;
104
- let sched : * mut T = & mut * * sched ;
105
- return sched ;
106
+ let ptr : * mut * mut c_void = & mut void_ptr ;
107
+ let ptr : * mut ~T = ptr as * mut ~T ;
108
+ let ptr : * mut T = & mut * * ptr ;
109
+ return ptr ;
106
110
}
107
111
}
108
112
0 commit comments