]>
git.proxmox.com Git - rustc.git/blob - src/libstd/sys/unix/ext/thread.rs
1 // Copyright 2015 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
11 //! Unix-specific extensions to primitives in the `std::process` module.
13 #![unstable(feature = "thread_extensions", issue = "29791")]
15 use os
::unix
::raw
::{pthread_t}
;
16 use sys_common
::{AsInner, IntoInner}
;
17 use thread
::{JoinHandle}
;
19 #[unstable(feature = "thread_extensions", issue = "29791")]
20 pub type RawPthread
= pthread_t
;
22 /// Unix-specific extensions to `std::thread::JoinHandle`
23 #[unstable(feature = "thread_extensions", issue = "29791")]
24 pub trait JoinHandleExt
{
25 /// Extracts the raw pthread_t without taking ownership
26 fn as_pthread_t(&self) -> RawPthread
;
27 /// Consumes the thread, returning the raw pthread_t
29 /// This function **transfers ownership** of the underlying pthread_t to
30 /// the caller. Callers are then the unique owners of the pthread_t and
31 /// must either detech or join the pthread_t once it's no longer needed.
32 fn into_pthread_t(self) -> RawPthread
;
35 #[unstable(feature = "thread_extensions", issue = "29791")]
36 impl<T
> JoinHandleExt
for JoinHandle
<T
> {
37 fn as_pthread_t(&self) -> RawPthread
{
38 self.as_inner().id() as RawPthread
40 fn into_pthread_t(self) -> RawPthread
{
41 self.into_inner().into_id() as RawPthread