@@ -87,31 +87,6 @@ pub struct StaticKey {
8787 dtor : Option < unsafe extern "C" fn ( * mut u8 ) > ,
8888}
8989
90- /// A type for a safely managed OS-based TLS slot.
91- ///
92- /// This type allocates an OS TLS key when it is initialized and will deallocate
93- /// the key when it falls out of scope. When compared with `StaticKey`, this
94- /// type is entirely safe to use.
95- ///
96- /// Implementations will likely, however, contain unsafe code as this type only
97- /// operates on `*mut u8`, a raw pointer.
98- ///
99- /// # Examples
100- ///
101- /// ```ignore (cannot-doctest-private-modules)
102- /// use tls::os::Key;
103- ///
104- /// let key = Key::new(None);
105- /// assert!(key.get().is_null());
106- /// key.set(1 as *mut u8);
107- /// assert!(!key.get().is_null());
108- ///
109- /// drop(key); // deallocate this TLS slot.
110- /// ```
111- pub struct Key {
112- key : imp:: Key ,
113- }
114-
11590/// Constant initialization value for static TLS keys.
11691///
11792/// This value specifies no destructor by default.
@@ -194,39 +169,3 @@ impl StaticKey {
194169 }
195170 }
196171}
197-
198- impl Key {
199- /// Creates a new managed OS TLS key.
200- ///
201- /// This key will be deallocated when the key falls out of scope.
202- ///
203- /// The argument provided is an optionally-specified destructor for the
204- /// value of this TLS key. When a thread exits and the value for this key
205- /// is non-null the destructor will be invoked. The TLS value will be reset
206- /// to null before the destructor is invoked.
207- ///
208- /// Note that the destructor will not be run when the `Key` goes out of
209- /// scope.
210- #[ inline]
211- pub fn new ( dtor : Option < unsafe extern "C" fn ( * mut u8 ) > ) -> Key {
212- Key { key : unsafe { imp:: create ( dtor) } }
213- }
214-
215- /// See StaticKey::get
216- #[ inline]
217- pub fn get ( & self ) -> * mut u8 {
218- unsafe { imp:: get ( self . key ) }
219- }
220-
221- /// See StaticKey::set
222- #[ inline]
223- pub fn set ( & self , val : * mut u8 ) {
224- unsafe { imp:: set ( self . key , val) }
225- }
226- }
227-
228- impl Drop for Key {
229- fn drop ( & mut self ) {
230- unsafe { imp:: destroy ( self . key ) }
231- }
232- }
0 commit comments