@@ -23,8 +23,8 @@ extern "C" {
2323
2424/// An opaque pointer to a thread.
2525///
26- /// This type does not detach on drop. It just leaks the thread. To detach or
27- /// join, call `detach_thread` or `join_thread` explicitly.
26+ /// This type does not detach or free resources on drop. It just leaks the
27+ /// thread. To detach or join, call [`detach`] or [`join`] explicitly.
2828#[ derive( Copy , Clone ) ]
2929pub struct Thread ( libc:: pthread_t ) ;
3030
@@ -63,7 +63,7 @@ impl Thread {
6363///
6464/// `fn_(arg)` on the new thread must have defined behavior, and the return
6565/// value must be valid to use on the eventual joining thread.
66- pub unsafe fn create_thread (
66+ pub unsafe fn create (
6767 fn_ : unsafe fn ( & mut [ * mut c_void ] ) -> Option < NonNull < c_void > > ,
6868 args : & [ Option < NonNull < c_void > > ] ,
6969 stack_size : usize ,
@@ -134,7 +134,7 @@ pub unsafe fn create_thread(
134134}
135135
136136/// Registers a function to call when the current thread exits.
137- pub fn at_thread_exit ( func : Box < dyn FnOnce ( ) > ) {
137+ pub fn at_exit ( func : Box < dyn FnOnce ( ) > ) {
138138 extern "C" fn call ( arg : * mut c_void ) {
139139 unsafe {
140140 let arg = arg. cast :: < Box < dyn FnOnce ( ) > > ( ) ;
@@ -153,7 +153,7 @@ pub fn at_thread_exit(func: Box<dyn FnOnce()>) {
153153/// Return a raw pointer to the data associated with the current thread.
154154#[ inline]
155155#[ must_use]
156- pub fn current_thread ( ) -> Thread {
156+ pub fn current ( ) -> Thread {
157157 unsafe { Thread ( libc:: pthread_self ( ) ) }
158158}
159159
@@ -163,7 +163,7 @@ pub fn current_thread() -> Thread {
163163/// field in the runtime rather than making a system call.
164164#[ inline]
165165#[ must_use]
166- pub fn current_thread_id ( ) -> ThreadId {
166+ pub fn current_id ( ) -> ThreadId {
167167 // Actually, in the pthread implementation here we do just make a system
168168 // call, because we don't have access to the pthread internals.
169169 rustix:: thread:: gettid ( )
@@ -192,7 +192,7 @@ pub unsafe fn set_current_thread_id_after_a_fork(tid: ThreadId) {
192192/// Return the TLS address for the given `offset` for the current thread.
193193#[ inline]
194194#[ must_use]
195- pub fn current_thread_tls_addr ( offset : usize ) -> * mut c_void {
195+ pub fn current_tls_addr ( offset : usize ) -> * mut c_void {
196196 let p = [ 1 , offset] ;
197197 unsafe { __tls_get_addr ( & p) }
198198}
@@ -233,7 +233,7 @@ pub unsafe fn thread_stack(thread: Thread) -> (*mut c_void, usize, usize) {
233233/// `thread` must point to a valid thread record that has not yet been detached
234234/// and will not be joined.
235235#[ inline]
236- pub unsafe fn detach_thread ( thread : Thread ) {
236+ pub unsafe fn detach ( thread : Thread ) {
237237 let thread = thread. 0 ;
238238
239239 assert_eq ! ( libc:: pthread_detach( thread) , 0 ) ;
@@ -248,7 +248,7 @@ pub unsafe fn detach_thread(thread: Thread) {
248248///
249249/// `thread` must point to a valid thread record that has not already been
250250/// detached or joined.
251- pub unsafe fn join_thread ( thread : Thread ) -> Option < NonNull < c_void > > {
251+ pub unsafe fn join ( thread : Thread ) -> Option < NonNull < c_void > > {
252252 let thread = thread. 0 ;
253253
254254 let mut return_value: * mut c_void = null_mut ( ) ;
@@ -289,7 +289,7 @@ pub fn default_guard_size() -> usize {
289289
290290/// Yield the current thread, encouraging other threads to run.
291291#[ inline]
292- pub fn yield_current_thread ( ) {
292+ pub fn yield_current ( ) {
293293 let _ = unsafe { libc:: sched_yield ( ) } ;
294294}
295295
0 commit comments