summary refs log tree commit diff
path: root/src/libstd/sys/unix/thread.rs
AgeCommit message (Collapse)AuthorLines
2015-08-11Stabilize the Duration APISteven Fackler-2/+2
This commit stabilizes the `std::time` module and the `Duration` type. `Duration::span` remains unstable, and the `Display` implementation for `Duration` has been removed as it is still being reworked and all trait implementations for stable types are de facto stable. This is a [breaking-change] to those using `Duration`'s `Display` implementation. Conflicts: src/librustc/lib.rs src/libstd/time/duration.rs
2015-07-21std: Be resilient to failure in pthread_getattr_npAlex Crichton-38/+50
This can fail on linux for various reasons, such as the /proc filesystem not being mounted. There are already many cases where we can't set up stack guards, so just don't worry about this case and communicate that no guard was enabled. I've confirmed that this allows the compiler to run in a chroot without /proc mounted. Closes #22642
2015-07-01Add netbsd amd64 supportAlex Newman-1/+5
2015-05-27Use `const fn` to abstract away the contents of UnsafeCell & friends.Eduard Burtescu-2/+2
2015-05-13std: Redesign Duration, implementing RFC 1040Alex Crichton-7/+2
This commit is an implementation of [RFC 1040][rfc] which is a redesign of the currently-unstable `Duration` type. The API of the type has been scaled back to be more conservative and it also no longer supports negative durations. [rfc]: https://github.com/rust-lang/rfcs/blob/master/text/1040-duration-reform.md The inner `duration` module of the `time` module has now been hidden (as `Duration` is reexported) and the feature name for this type has changed from `std_misc` to `duration`. All APIs accepting durations have also been audited to take a more flavorful feature name instead of `std_misc`. Closes #24874
2015-04-27std: Don't assume dlopen() works on yourselfAlex Crichton-1/+4
Statically linked executables do not succeed (aka MUSL-based executables).
2015-04-22std: Audit std::thread implementationsAlex Crichton-130/+144
Much of this code hasn't been updated in quite some time and this commit does a small audit of the functionality: * Implementation functions now centralize all functionality on a locally defined `Thread` type. * The `detach` method has been removed in favor of a `Drop` implementation. This notably fixes leaking thread handles on Windows. * The `Thread` structure is now appropriately annotated with `Send` and `Sync` automatically on Windows and in a custom fashion on Unix. * The unsafety of creating a thread has been pushed out to the right boundaries now. Closes #24442
2015-04-08std: Stabilize io::Error::from_raw_os_errorAlex Crichton-1/+1
This commit stabilizes the old `io::Error::from_os_error` after being renamed to use the `raw_os_error` terminology instead. This function is often useful when writing bindings to OS functions but only actually converting to an I/O error at a later point.
2015-03-23Test fixes and rebase conflicts, round 2Alex Crichton-2/+3
2015-03-23rollup merge of #23640: nagisa/thread-less-weakAlex Crichton-11/+8
This is more portable as far as linux is concerned.
2015-03-23prctl instead of pthread on linux for name setupSimonas Kazlauskas-11/+8
This is more portable as far as linux is concerned.
2015-03-23min_stack_size: clarify both reasons to use dlsymAnders Kaseorg-5/+6
Signed-off-by: Anders Kaseorg <andersk@mit.edu>
2015-03-23min_stack_size: update non-Linux implementation commentAnders Kaseorg-2/+2
Signed-off-by: Anders Kaseorg <andersk@mit.edu>
2015-03-23Get __pthread_get_minstack at runtime with dlsymAnders Kaseorg-12/+23
Linking __pthread_get_minstack, even weakly, was causing Debian’s dpkg-shlibdeps to detect an unnecessarily strict versioned dependency on libc6. Closes #23628. Signed-off-by: Anders Kaseorg <andersk@mit.edu>
2015-03-18openbsd/bitrig threadsSébastien Marie-4/+2
- remove `pub` from `struct` (visibility has no effect inside functions) - move `pthread_main_np` into function
2015-03-17std: Implement `thread::sleep`Alex Crichton-1/+15
This function is the current replacement for `std::old_io::timer` which will soon be deprecated. This function is unstable and has its own feature gate as it does not yet have an RFC nor has it existed for very long.
2015-03-15std: Clean up the sys::thread modulesAlex Crichton-181/+123
This module had become a #[cfg] jungle, try to bring at least a small semblance of order to it!
2015-03-12std: Remove #[allow] directives in sys modulesAlex Crichton-4/+7
These were suppressing lots of interesting warnings! Turns out there was also quite a bit of dead code.
2015-02-28openbsd: adjust page guard addressSébastien Marie-1/+1
some commits in OpenBSD base have corrected a problem of stack position. Now, we can adjust more accurately the page guard in rust.
2015-02-23Use boxed functions instead of transmuteStepan Koltsov-2/+5
... to convert between Box and raw pointers. E. g. use ``` let b: Box<Foo> = Box::from_raw(p); ``` instead of ``` let b: Box<Foo> = mem::transmute(p); ``` Patch also changes closure release code in `src/libstd/sys/unix/thread.rs` when `pthread_create` failed. Raw pointer was transmuted to box of `FnOnce()` instead of `Thunk`. This code was probably never executed, because `pthread_create` rarely fails in practice.
2015-02-21Auto merge of #21959 - dhuseby:bitrig-support, r=brsonbors-2/+33
This patch adds the necessary pieces to support rust on Bitrig https://bitrig.org
2015-02-18std: Implement CString-related RFCsAlex Crichton-3/+3
This commit is an implementation of [RFC 592][r592] and [RFC 840][r840]. These two RFCs tweak the behavior of `CString` and add a new `CStr` unsized slice type to the module. [r592]: https://github.com/rust-lang/rfcs/blob/master/text/0592-c-str-deref.md [r840]: https://github.com/rust-lang/rfcs/blob/master/text/0840-no-panic-in-c-string.md The new `CStr` type is only constructable via two methods: 1. By `deref`'ing from a `CString` 2. Unsafely via `CStr::from_ptr` The purpose of `CStr` is to be an unsized type which is a thin pointer to a `libc::c_char` (currently it is a fat pointer slice due to implementation limitations). Strings from C can be safely represented with a `CStr` and an appropriate lifetime as well. Consumers of `&CString` should now consume `&CStr` instead to allow producers to pass in C-originating strings instead of just Rust-allocated strings. A new constructor was added to `CString`, `new`, which takes `T: IntoBytes` instead of separate `from_slice` and `from_vec` methods (both have been deprecated in favor of `new`). The `new` method returns a `Result` instead of panicking. The error variant contains the relevant information about where the error happened and bytes (if present). Conversions are provided to the `io::Error` and `old_io::IoError` types via the `FromError` trait which translate to `InvalidInput`. This is a breaking change due to the modification of existing `#[unstable]` APIs and new deprecation, and more detailed information can be found in the two RFCs. Notable breakage includes: * All construction of `CString` now needs to use `new` and handle the outgoing `Result`. * Usage of `CString` as a byte slice now explicitly needs a `.as_bytes()` call. * The `as_slice*` methods have been removed in favor of just having the `as_bytes*` methods. Closes #22469 Closes #22470 [breaking-change]
2015-02-17Revise std::thread semanticsAaron Turon-3/+5
This commit makes several changes to `std::thread` in preparation for final stabilization: * It removes the ability to handle panics from `scoped` children; see #20807 for discussion * It adds a `JoinHandle` structure, now returned from `spawn`, which makes it possible to join on children that do not share data from their parent's stack. The child is automatically detached when the handle is dropped, and the handle cannot be copied due to Posix semantics. * It moves all static methods from `std::thread::Thread` to free functions in `std::thread`. This was done in part because, due to the above changes, there are effectively no direct `Thread` constructors, and the static methods have tended to feel a bit awkward. * Adds an `io::Result` around the `Builder` methods `scoped` and `spawn`, making it possible to handle OS errors when creating threads. The convenience free functions entail an unwrap. * Stabilizes the entire module. Despite the fact that the API is changing somewhat here, this is part of a long period of baking and the changes are addressing all known issues prior to alpha2. If absolutely necessary, further breaking changes can be made prior to beta. Closes #20807 [breaking-change]
2015-02-11fixing trailing whitespace errorsDave Huseby-1/+1
2015-02-11bitrig integrationDave Huseby-2/+33
2015-02-01openbsd: rebase to masterSébastien Marie-3/+6
- incoporate changes introduced by #21678
2015-02-01openbsd supportSébastien Marie-5/+45
2015-01-28Thread native name setting, fix #10302Vojtech Kral-1/+1
2015-01-28Thread native name setting, fix #10302Vojtech Kral-1/+1
2015-01-28Thread native name setting, fix #10302Vojtech Kral-15/+14
2015-01-27Thread native name setting, fix #10302Vojtech Kral-2/+2
2015-01-27Thread native name setting, fix #10302Vojtech Kral-0/+40
2015-01-11Give mmap a page-aligned stack start addressClifford Caoile-1/+13
2014-12-18Revise std::thread API to join by defaultAaron Turon-3/+4
This commit is part of a series that introduces a `std::thread` API to replace `std::task`. In the new API, `spawn` returns a `JoinGuard`, which by default will join the spawned thread when dropped. It can also be used to join explicitly at any time, returning the thread's result. Alternatively, the spawned thread can be explicitly detached (so no join takes place). As part of this change, Rust processes now terminate when the main thread exits, even if other detached threads are still running, moving Rust closer to standard threading models. This new behavior may break code that was relying on the previously implicit join-all. In addition to the above, the new thread API also offers some built-in support for building blocking abstractions in user space; see the module doc for details. Closes #18000 [breaking-change]
2014-12-18libs: merge librustrt into libstdAaron Turon-0/+270
This commit merges the `rustrt` crate into `std`, undoing part of the facade. This merger continues the paring down of the runtime system. Code relying on the public API of `rustrt` will break; some of this API is now available through `std::rt`, but is likely to change and/or be removed very soon. [breaking-change]