Commit Graph

128 Commits

Author SHA1 Message Date
Stephen M. Coakley e80fd2531b Use mutex to guard thread ID counter 2016-10-05 18:11:28 -05:00
Stephen M. Coakley 894ef966c6 Generate ID using u64 + atomic spinlock 2016-10-05 11:34:25 -05:00
Stephen M. Coakley 6e10e29a97 Fix tests 2016-09-08 00:08:15 -05:00
Stephen M. Coakley 5bd834bdb4 Add ThreadId for comparing threads 2016-09-07 23:48:07 -05:00
Andrew Paseltiner 8d3fd03855 Clean up thread-local storage docs
`std` no longer contains an implementation of scoped TLS.
2016-09-04 10:16:25 -04:00
Guillaume Gomez 23f769881a Rollup merge of #35997 - matthew-piziak:thread-current-example, r=GuillaumeGomez
add a simple example for `thread::current()`

r? @GuillaumeGomez
2016-08-30 10:39:07 +02:00
Matthew Piziak cf8e1fee16 add a simple example for thread::current() 2016-08-25 16:20:21 -04:00
Jeffrey Seyfried 9a2c8783d9 Use #[prelude_import] in libstd. 2016-08-24 22:12:48 +00:00
Stefan Schindler 20721a4923 Add link to replacement function 2016-08-03 23:12:25 +02:00
Stefan Schindler 4fc6f5ac26 Add an example to std::thread::park_timeout 2016-08-03 23:12:25 +02:00
Guillaume Gomez 5d6b41f3bc Rollup merge of #34406 - frewsxcv:sleep-ex, r=alexcrichton
Add example for `std::thread::sleep`.

None
2016-06-28 16:05:14 +02:00
Corey Farwell a7b9e5441b Add example for std::thread::sleep. 2016-06-27 13:06:20 -04:00
bors 2cfd91d0ce Auto merge of #34465 - frewsxcv:builder-name-example, r=GuillaumeGomez
Add doc example for `std::thread::Builder::name`.

None
2016-06-25 15:47:31 -07:00
bors 91c0d04943 Auto merge of #34410 - frewsxcv:code-like, r=apasel422
Parameters in doc comment should be formatted code-like.

None
2016-06-25 13:01:31 -07:00
Manish Goregaokar 80b352c892 Rollup merge of #34438 - frewsxcv:joinhandle, r=GuillaumeGomez
Indicate how the `JoinHandle` struct is created.

None
2016-06-25 18:16:40 +05:30
Corey Farwell fd388d40ed Add doc example for std::thread::Builder::name. 2016-06-25 07:22:19 -04:00
Corey Farwell 5e9b75e2dd Add examples in docs for JoinHandle. 2016-06-24 12:25:26 -04:00
Corey Farwell 0a6ce30161 Use Option::expect instead of unwrap_or_else with panic!. 2016-06-24 08:19:22 -04:00
Corey Farwell 6e848be5f8 Indicate how the JoinHandle struct is created. 2016-06-24 08:13:30 -04:00
bors 4d9faf3632 Auto merge of #34077 - durka:patch-23, r=alexcrichton
upgrade thread_local! invocation syntax

Allows declaring multiple statics in one macro invocation, and supports attaching attributes to the generated items. In particular, `#![forbid(missing_docs, unused)]` is now tenable on a crate/module containing thread locals.

For an example see [here](https://is.gd/aVFZZF). This change is fully backwards compatible as far as I can tell.

cc @frankmcsherry
2016-06-23 19:22:51 -07:00
Alex Burka fc28ee256a upgrade thread_local! invocation syntax
Allows declaring multiple statics in one macro invocation, and supports attaching attributes to the generated items.
2016-06-22 20:29:37 -04:00
Corey Farwell 64137c485a Parameters in doc comment should be formatted code-like. 2016-06-22 08:24:16 -04:00
Guillaume Gomez 592c314baf Rollup merge of #34371 - frewsxcv:thread-name, r=steveklabnik
Add examples for `std::thread::Thread::name`.

None
2016-06-21 23:54:28 +02:00
Corey Farwell d5a27594a3 Add examples for std::thread::Thread::name. 2016-06-19 17:55:57 -04:00
Corey Farwell 9944b223a2 Add example in docs for std::thread::panicking. 2016-06-18 00:17:36 +02:00
Alex Crichton b64c9d5670 std: Clean out old unstable + deprecated APIs
These should all have been deprecated for at least one cycle, so this commit
cleans them all out.
2016-05-30 20:46:32 -07:00
Pyry Kontio 20b9129617 Added a big-picture explanation for thread::park() & co. 2016-05-16 14:01:21 +09:00
Alex Crichton 0ec321f7b5 rustc: Implement custom panic runtimes
This commit is an implementation of [RFC 1513] which allows applications to
alter the behavior of panics at compile time. A new compiler flag, `-C panic`,
is added and accepts the values `unwind` or `panic`, with the default being
`unwind`. This model affects how code is generated for the local crate, skipping
generation of landing pads with `-C panic=abort`.

[RFC 1513]: https://github.com/rust-lang/rfcs/blob/master/text/1513-less-unwinding.md

Panic implementations are then provided by crates tagged with
`#![panic_runtime]` and lazily required by crates with
`#![needs_panic_runtime]`. The panic strategy (`-C panic` value) of the panic
runtime must match the final product, and if the panic strategy is not `abort`
then the entire DAG must have the same panic strategy.

With the `-C panic=abort` strategy, users can expect a stable method to disable
generation of landing pads, improving optimization in niche scenarios,
decreasing compile time, and decreasing output binary size. With the `-C
panic=unwind` strategy users can expect the existing ability to isolate failure
in Rust code from the outside world.

Organizationally, this commit dismantles the `sys_common::unwind` module in
favor of some bits moving part of it to `libpanic_unwind` and the rest into the
`panicking` module in libstd. The custom panic runtime support is pretty similar
to the custom allocator support with the only major difference being how the
panic runtime is injected (takes the `-C panic` flag into account).
2016-05-09 08:22:36 -07:00
Georg Brandl eba43fb5c3 std::thread docs: spawn() returns not a Thread anymore
Also move the "Thread type" section down a bit, since it is
not so important anymore.

Fixes: #33321
2016-05-02 06:17:51 +02:00
Ryman 2b71219a61 libstd: fix typos in thread::LocalKey docs 2016-04-25 21:01:19 +01:00
David Henningsson 78495d5082 Fix unsound behaviour with null characters in thread names (issue #32475)
Previously, the thread name (&str) was converted to a CString in the
new thread, but outside unwind::try, causing a panic to continue into FFI.

This patch changes that behaviour, so that the panic instead happens
in the parent thread (where panic infrastructure is properly set up),
not the new thread.

This could potentially be a breaking change for architectures who don't
support thread names.

Signed-off-by: David Henningsson <diwic@ubuntu.com>
2016-03-25 06:14:03 +01:00
Jorge Aparicio 0f02309e4b try! -> ?
Automated conversion using the untry tool [1] and the following command:

```
$ find -name '*.rs' -type f | xargs untry
```

at the root of the Rust repo.

[1]: https://github.com/japaric/untry
2016-03-22 22:01:37 -05:00
Alex Crichton b53764c73b std: Clean out deprecated APIs
Removes all unstable and deprecated APIs prior to the 1.8 release. All APIs that
are deprecated in the 1.8 release are sticking around for the rest of this
cycle.

Some notable changes are:

* The `dynamic_lib` module was moved into `rustc_back` as the compiler still
  relies on a few bits and pieces.
* The `DebugTuple` formatter now special-cases an empty struct name with only
  one field to append a trailing comma.
2016-03-12 12:31:13 -08:00
Steve Klabnik 096409cf8c End stdlib module summaries with a full stop.
Fixes #9447
2016-03-04 17:37:11 -05:00
Alex Crichton b643782a10 std: Stabilize APIs for the 1.8 release
This commit is the result of the FCPs ending for the 1.8 release cycle for both
the libs and the lang suteams. The full list of changes are:

Stabilized

* `braced_empty_structs`
* `augmented_assignments`
* `str::encode_utf16` - renamed from `utf16_units`
* `str::EncodeUtf16` - renamed from `Utf16Units`
* `Ref::map`
* `RefMut::map`
* `ptr::drop_in_place`
* `time::Instant`
* `time::SystemTime`
* `{Instant,SystemTime}::now`
* `{Instant,SystemTime}::duration_since` - renamed from `duration_from_earlier`
* `{Instant,SystemTime}::elapsed`
* Various `Add`/`Sub` impls for `Time` and `SystemTime`
* `SystemTimeError`
* `SystemTimeError::duration`
* Various impls for `SystemTimeError`
* `UNIX_EPOCH`
* `ops::{Add,Sub,Mul,Div,Rem,BitAnd,BitOr,BitXor,Shl,Shr}Assign`

Deprecated

* Scoped TLS (the `scoped_thread_local!` macro)
* `Ref::filter_map`
* `RefMut::filter_map`
* `RwLockReadGuard::map`
* `RwLockWriteGuard::map`
* `Condvar::wait_timeout_with`

Closes #27714
Closes #27715
Closes #27746
Closes #27748
Closes #27908
Closes #29866
2016-02-29 09:05:33 -08:00
Manish Goregaokar 6c4f0bf79b Stop using unsafe code in TLS macro expansion (fixes #30756) 2016-02-04 22:23:20 +05:30
Alex Crichton b960de0984 std: Ignore dtors_in_dtors_in_dtors on OSX
This test has been deadlocking and causing problems on the bots basically since
its inception. Some memory safety issues were fixed in 987dc84b, but the
deadlocks remained afterwards unfortunately.

After some investigation, I've concluded that this is just a situation where OSX
is not guaranteed to run destructors. The fix in 987dc84b observed that OSX was
rewriting the backing TLS memory to its initial state during destruction while
we weren't looking, and this would have the effect of canceling the destructors
of any other initialized TLS slots.

While very difficult to pin down, this is basically what I assume is happening
here, so there doesn't seem to really be anythig we can do to ensure the test
robustly passes on OSX, so just ignore it for now.
2016-01-29 13:46:47 -08:00
Amanieu d'Antras e304fb43a3 Replace no_elf_tls with target_thread_local 2016-01-11 10:38:36 +00:00
Florian Hahn e27cbeff37 Fix warnings when compiling stdlib with --test 2015-12-29 16:07:01 +01:00
Alex Crichton cd74364e5d std: Use cfg(target_thread_local) in thread_local!
This transitions the standard library's `thread_local!` macro to use the
freshly-added and gated `#[cfg(target_thread_local)]` attribute. This greatly
simplifies the `#[cfg]` logic in play here, but requires that the standard
library expose both the OS and ELF TLS implementation modules as unstable
implementation details.

The implementation details were shuffled around a bit but end up generally
compiling to the same thing.

Closes #26581 (this supersedes the need for the option)
Closes #27057 (this also starts ignoring the option)
2015-12-21 22:05:37 -08:00
bors ce132752c6 Auto merge of #30267 - alexcrichton:tls-init-oh-my, r=nikomatsakis
Due to #30228 it's not currently sound to do `*ptr = Some(value)`, so instead
use `mem::replace` which fixes the soundness hole for now.
2015-12-10 18:11:32 +00:00
Alex Crichton 0a13f1abaf std: Rename thread::catch_panic to panic::recover
This commit is an implementation of [RFC 1236] and [RFC 1323] which
rename the `thread::catch_panic` function to `panic::recover` while also
replacing the `Send + 'static` bounds with a new `PanicSafe` bound.

[RFC 1236]: https://github.com/rust-lang/rfcs/pull/1236
[RFC 1323]: https://github.com/rust-lang/rfcs/pull/1323

cc #27719
2015-12-09 07:19:17 -08:00
Alex Crichton 9e0ff773ad std: Use mem::replace in TLS initialization
Due to #30228 it's not currently sound to do `*ptr = Some(value)`, so instead
use `mem::replace` which fixes the soundness hole for now.
2015-12-08 12:23:22 -08:00
Peter Atashian 95cdada99a AsRawHandle and IntoRawHandle for JoinHandle
This allows users to get the HANDLE of a spawned thread on Windows

Signed-off-by: Peter Atashian <retep998@gmail.com>
2015-12-04 20:09:30 -05:00
Vadim Petrochenkov a613059e3f Rename #[deprecated] to #[rustc_deprecated] 2015-11-20 16:11:20 +03:00
Vadim Petrochenkov 7e2ffc7090 Add missing annotations and some tests 2015-11-18 01:24:21 +03:00
Ben Striegel a2efa2aa29 Deprecate _ms functions that predate the Duration API 2015-11-04 18:43:30 -08:00
Alexis Beingessner e351595c61 don't use drop_in_place as an intrinsic 2015-10-30 11:24:54 -04:00
arcnmx 1303687d48 Clean up thread::spawn 2015-10-18 20:03:09 -04:00
Ariel Ben-Yehuda ce70207250 fix fallout
looks like some mix of #18653 and `projection_must_outlive`, but
that needs to be investigated further (crater run?)
2015-10-02 23:40:10 +03:00