<feed xmlns='http://www.w3.org/2005/Atom'>
<title>rust/src/libstd/thread, branch 1.32.0</title>
<subtitle>https://github.com/rust-lang/rust
</subtitle>
<id>http://git.dreamy.place/mirrors/rust/atom?h=1.32.0</id>
<link rel='self' href='http://git.dreamy.place/mirrors/rust/atom?h=1.32.0'/>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/'/>
<updated>2018-11-27T17:57:55+00:00</updated>
<entry>
<title>Fix small typo in comment</title>
<updated>2018-11-27T17:57:55+00:00</updated>
<author>
<name>Marius Nuennerich</name>
<email>marius@nuenneri.ch</email>
</author>
<published>2018-11-27T17:57:55+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=73b656bbb306047d072b41321153b62c5a4a2b0d'/>
<id>urn:sha1:73b656bbb306047d072b41321153b62c5a4a2b0d</id>
<content type='text'>
</content>
</entry>
<entry>
<title>fix various typos in doc comments</title>
<updated>2018-11-13T19:45:31+00:00</updated>
<author>
<name>Andy Russell</name>
<email>arussell123@gmail.com</email>
</author>
<published>2018-11-12T18:05:20+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=4e35cbb22eceac145a6f794cde869b3684e0b1d5'/>
<id>urn:sha1:4e35cbb22eceac145a6f794cde869b3684e0b1d5</id>
<content type='text'>
</content>
</entry>
<entry>
<title>Rollup merge of #55597 - alexcrichton:thread-local-inner, r=KodrAus</title>
<updated>2018-11-06T09:08:03+00:00</updated>
<author>
<name>kennytm</name>
<email>kennytm@gmail.com</email>
</author>
<published>2018-11-06T07:20:59+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=462f63e1bbb59f1e4cea5272028e85852f9129aa'/>
<id>urn:sha1:462f63e1bbb59f1e4cea5272028e85852f9129aa</id>
<content type='text'>
std: Enable usage of `thread_local!` through imports

The `thread_local!` macro delegated to an internal macro but it didn't
do so in a macros-and-the-module-system compatible fashion, meaning if a
`#![no_std]` crate imported `std` and tried to use `thread_local!` it
would fail due to missing a lookup of an internal macro.

This commit switches the macro to instead use `$crate` to invoke other
macros, ensuring that it'll work when `thread_local!` is imported alone.
</content>
</entry>
<entry>
<title>std: Enable usage of `thread_local!` through imports</title>
<updated>2018-11-01T21:17:39+00:00</updated>
<author>
<name>Alex Crichton</name>
<email>alex@alexcrichton.com</email>
</author>
<published>2018-11-01T21:17:39+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=ff5226cd2fa12fe82c7cef8112905af7cb48fe9d'/>
<id>urn:sha1:ff5226cd2fa12fe82c7cef8112905af7cb48fe9d</id>
<content type='text'>
The `thread_local!` macro delegated to an internal macro but it didn't
do so in a macros-and-the-module-system compatible fashion, meaning if a
`#![no_std]` crate imported `std` and tried to use `thread_local!` it
would fail due to missing a lookup of an internal macro.

This commit switches the macro to instead use `$crate` to invoke other
macros, ensuring that it'll work when `thread_local!` is imported alone.
</content>
</entry>
<entry>
<title>std: Improve codegen size of accessing TLS</title>
<updated>2018-11-01T17:46:31+00:00</updated>
<author>
<name>Alex Crichton</name>
<email>alex@alexcrichton.com</email>
</author>
<published>2018-10-28T15:26:47+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=0c3d08e9676a7defd16b88307838f7294d28c3e5'/>
<id>urn:sha1:0c3d08e9676a7defd16b88307838f7294d28c3e5</id>
<content type='text'>
Some code in the TLS implementation in libstd stores `Some(val)` into an
`&amp;mut Option&lt;T&gt;` (effectively) and then pulls out `&amp;T`, but it currently
uses `.unwrap()` which can codegen into a panic even though it can never
panic. With sufficient optimizations enabled (like LTO) the compiler can
see through this but this commit helps it along in normal mode
(`--release` with Cargo by default) to avoid codegen'ing the panic path.

This ends up improving the optimized codegen on wasm by ensuring that a
call to panic pulling in more file size doesn't stick around.
</content>
</entry>
<entry>
<title>thread::unpark: Avoid notifying with mutex locked.</title>
<updated>2018-10-30T22:54:35+00:00</updated>
<author>
<name>James Duley</name>
<email>james.duley@arm.com</email>
</author>
<published>2018-09-21T14:13:39+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=d3e71e4986c3970d2f51b972c1dfdd740f89385a'/>
<id>urn:sha1:d3e71e4986c3970d2f51b972c1dfdd740f89385a</id>
<content type='text'>
This means when the other thread wakes it can continue right away
instead of having to wait for the mutex.

Also add some comments explaining why the mutex needs to be locked in
the first place.
</content>
</entry>
<entry>
<title>Auto merge of #55043 - oliver-giersch:unchecked_thread_spawning, r=alexcrichton</title>
<updated>2018-10-28T21:34:12+00:00</updated>
<author>
<name>bors</name>
<email>bors@rust-lang.org</email>
</author>
<published>2018-10-28T21:34:12+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=bcb05a0ab23291851d0a233547f2ad3cbb9cc222'/>
<id>urn:sha1:bcb05a0ab23291851d0a233547f2ad3cbb9cc222</id>
<content type='text'>
Unchecked thread spawning

# Summary

Add an unsafe interface for spawning lifetime-unrestricted threads for
library authors to build less-contrived, less-hacky safe abstractions
on.

# Motivation

So a few years back scoped threads were entirely removed from the Rust
stdlib, the reason being that it was possible to leak the scoped thread's
join guards without resorting to unsafe code, which meant the concept
was not completely safe, either.
Only a maximally-restrictive safe API for thread spawning was kept in the
stdlib, that requires `'static` lifetime bounds on both the thread closure
and its return type.
A number of 3rd party libraries sprung up to offer their implementations
for safe scoped threads implementations.
These work by essentially hiding the join guards from the user, thus
forcing them to join at the end of an (internal) function scope.

However, since these libraries have to use the maximally restrictive
thread spawning API, they have to resort to some very contrived manipulations
and subversions of Rust's type system to basically achieve what this commit does
with some minimal restructuring of the current code and exposing a new unsafe
function signature for spawning threads without lifetime restrictions.
Obviously this is unsafe, but its main use would be to allow library authors
to write safe abstractions with and around it.
To further illustrate my point, here's a quick summary of the hoops that,
for instance `crossbeam`, has to jump through to spawn a lifetime unrestricted
thread, all of which would not be necessary if an unsafe API existed as part
of the stdlib:

1. Allocate an `Arc&lt;Option&lt;T&gt;&gt;` on the heap where the result with type
`T: 'a` will go (in practice requires `Mutex` or `UnsafeCell` as well).

2. Wrap the desired thread closure with lifetime bound `'a` into another
closure (also `..: 'a`) that returns `()`, executes the inner closure and
writes its result into the pre-allocated `Option&lt;T&gt;`.

3. Box the wrapping closure, cast it to a trait object (`FnBox`) and
(unsafely) transmute its lifetime bound from `'a` to `'static`.

So while this new `spawn_unchecked` function is certainly not very relevant
for general use, since scoped threads are so common I think it makes sense
to expose an interface for libraries implementing these to build on.
The changes implemented are also very minimal: The current `spawn` function
(which internally contains unsafe code) is moved into an unsafe `spawn_unchecked`
function, which the safe function then wraps around.

# Issues

- ~~so far, no documentation for the new function (yet)~~
- the name of the function might be controversial, as `*_unchecked` more commonly
indicates that some sort of runtime check is omitted (`unrestricted` may be
more fitting)
- if accepted, it might make sense to add a freestanding `thread::spawn_unchecked`
function similar to the current `thread::spawn` for convenience.
</content>
</entry>
<entry>
<title>Rollup merge of #54646 - vn971:fix_std_thread_sleep, r=frewsxcv</title>
<updated>2018-10-18T04:54:42+00:00</updated>
<author>
<name>kennytm</name>
<email>kennytm@gmail.com</email>
</author>
<published>2018-10-18T02:47:17+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=e4ac4478514779d956cbc51068ec2d3207083bfa'/>
<id>urn:sha1:e4ac4478514779d956cbc51068ec2d3207083bfa</id>
<content type='text'>
improve documentation on std::thread::sleep
</content>
</entry>
<entry>
<title>adds tracking issue number</title>
<updated>2018-10-16T20:42:14+00:00</updated>
<author>
<name>oliver-giersch</name>
<email>oliver.giersch@googlemail.com</email>
</author>
<published>2018-10-16T20:42:14+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=7849aeddb9de12cd7dadc3953cb581695717130b'/>
<id>urn:sha1:7849aeddb9de12cd7dadc3953cb581695717130b</id>
<content type='text'>
</content>
</entry>
<entry>
<title>Merge pull request #5 from oliver-giersch/master</title>
<updated>2018-10-15T12:38:34+00:00</updated>
<author>
<name>oliver-giersch</name>
<email>oliver.giersch@googlemail.com</email>
</author>
<published>2018-10-15T12:38:34+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=30bfdc872020c6addcb2ea488b2a6dbdd5ef355a'/>
<id>urn:sha1:30bfdc872020c6addcb2ea488b2a6dbdd5ef355a</id>
<content type='text'>
sync with upstream</content>
</entry>
</feed>
