Commit Graph

61 Commits

Author SHA1 Message Date
Huon Wilson
6555b04dd2 Spellcheck library docs. 2014-02-18 08:05:35 +11:00
Kevin Ballard
66bed17641 Remove Freeze bounds from sync::MutexArc
With Rc no longer trying to statically prevent cycles (and thus no
longer using the Freeze bound), it seems appropriate to remove that
restriction from MutexArc as well.
2014-02-16 21:14:15 -08:00
bors
d98668a559 auto merge of #12235 : huonw/rust/raii-lock, r=alexcrichton
- adds a `LockGuard` type returned by `.lock` and `.trylock` that unlocks the mutex in the destructor
- renames `mutex::Mutex` to `StaticNativeMutex` 
- adds a `NativeMutex` type with a destructor
- removes `LittleLock`
- adds `#[must_use]` to `sync::mutex::Guard` to remind people to use it
2014-02-15 15:21:28 -08:00
Huon Wilson
0f4294b4e2 sync: Add #[must_use] to the Mutex guard.
This helps people remember to save the return value to keep the mutex
locked as appropriate.
2014-02-16 10:13:56 +11:00
Huon Wilson
b87ed605c0 std: Rename unstable::mutex::Mutex to StaticNativeMutex.
This better reflects its purpose and design.
2014-02-16 10:13:56 +11:00
Huon Wilson
76a59fd6e2 std: add an RAII unlocker to Mutex.
This automatically unlocks its lock when it goes out of scope, and
provides a safe(ish) method to call .wait.
2014-02-16 10:13:56 +11:00
Alex Crichton
a41b0c2529 extern mod => extern crate
This was previously implemented, and it just needed a snapshot to go through
2014-02-14 22:55:21 -08:00
Alex Crichton
0a6b9219d1 Rewrite channels yet again for upgradeability
This, the Nth rewrite of channels, is not a rewrite of the core logic behind
channels, but rather their API usage. In the past, we had the distinction
between oneshot, stream, and shared channels, but the most recent rewrite
dropped oneshots in favor of streams and shared channels.

This distinction of stream vs shared has shown that it's not quite what we'd
like either, and this moves the `std::comm` module in the direction of "one
channel to rule them all". There now remains only one Chan and one Port.

This new channel is actually a hybrid oneshot/stream/shared channel under the
hood in order to optimize for the use cases in question. Additionally, this also
reduces the cognitive burden of having to choose between a Chan or a SharedChan
in an API.

My simple benchmarks show no reduction in efficiency over the existing channels
today, and a 3x improvement in the oneshot case. I sadly don't have a
pre-last-rewrite compiler to test out the old old oneshots, but I would imagine
that the performance is comparable, but slightly slower (due to atomic reference
counting).

This commit also brings the bonus bugfix to channels that the pending queue of
messages are all dropped when a Port disappears rather then when both the Port
and the Chan disappear.
2014-02-11 16:32:00 -08:00
Edward Wang
e9ff91e9be Move replace and swap to std::mem. Get rid of std::util
Also move Void to std::any, move drop to std::mem and reexport in
prelude.
2014-02-11 05:21:35 +08:00
Colin Sherratt
0640fc3a8c Added missing export of CowArc 2014-02-07 21:47:23 -05:00
JeremyLetang
dd21a51d29 move concurrent stuff from libextra to libsync 2014-02-05 11:56:04 -05:00