Commit Graph

51 Commits

Author SHA1 Message Date
bors
bb31cb8d2e auto merge of #13286 : alexcrichton/rust/release, r=brson
Merging the 0.10 release into the master branch.
2014-04-03 13:52:03 -07:00
Alex Crichton
a49ce7f11a sync: Switch field privacy as necessary 2014-03-31 15:47:35 -07:00
Alex Crichton
a5681d2590 Bump version to 0.10 2014-03-31 14:40:44 -07:00
bors
2674a16c18 auto merge of #13211 : csherratt/rust/arc_fix, r=alexcrichton
This is a fix for #13210. fetch_sub returns the old value of the atomic variable, not the new one.
2014-03-30 16:01:43 -07:00
Colin Sherratt
9fc45c1f8e Check that the old value was 1 and not 0 when dropping a Arc value.
Closed #13210.
2014-03-30 15:14:43 -04:00
Brian Anderson
451e8c1c61 Convert most code to new inner attribute syntax.
Closes #2569
2014-03-28 17:12:21 -07:00
Flavio Percoco
81ec1f3c18 Rename Pod into Copy
Summary:
So far, we've used the term POD "Plain Old Data" to refer to types that
can be safely copied. However, this term is not consistent with the
other built-in bounds that use verbs instead. This patch renames the Pod
kind into Copy.

RFC: 0003-opt-in-builtin-traits

Test Plan: make check

Reviewers: cmr

Differential Revision: http://phabricator.octayn.net/D3
2014-03-28 10:34:02 +01:00
Alex Crichton
bb9172d7b5 Fix fallout of removing default bounds
This is all purely fallout of getting the previous commit to compile.
2014-03-27 10:14:50 -07:00
Alex Crichton
56cae9b3c0 comm: Implement synchronous channels
This commit contains an implementation of synchronous, bounded channels for
Rust. This is an implementation of the proposal made last January [1]. These
channels are built on mutexes, and currently focus on a working implementation
rather than speed. Receivers for sync channels have select() implemented for
them, but there is currently no implementation of select() for sync senders.

Rust will continue to provide both synchronous and asynchronous channels as part
of the standard distribution, there is no intent to remove asynchronous
channels. This flavor of channels is meant to provide an alternative to
asynchronous channels because like green tasks, asynchronous channels are not
appropriate for all situations.

[1] - https://mail.mozilla.org/pipermail/rust-dev/2014-January/007924.html
2014-03-24 20:06:37 -07:00
Alex Crichton
eff025797a sync: Wire up all of the previous commits
This updates the exports and layout of the crate
2014-03-24 17:17:46 -07:00
Alex Crichton
64a52de823 sync: Update the arc module
This removes the now-outdated MutexArc and RWArc types. These are superseded by
Arc<Mutex<T>> and Arc<RWLock<T>>. The only remaining arc is the one true Arc.
Additionally, the arc now has weak pointers implemented for it to assist in
breaking cycles.

This commit brings the arc api up to parity with the sibling Rc api, making them
nearly interchangeable for inter and intra task communication.
2014-03-24 17:17:46 -07:00
Alex Crichton
4d5aafd3a6 sync: Introduce new wrapper types for locking
This introduces new synchronization types which are meant to be the foundational
building blocks for sharing data among tasks. The new Mutex and RWLock types
have a type parameter which is the internal data that is accessed. Access to the
data is all performed through the guards returned, and the guards all have
autoderef implemented for easy access.
2014-03-23 09:45:20 -07:00
Alex Crichton
ae049e82f8 sync: Rewrite the base primitives
This commit rewrites the core primitives of the sync library: Mutex, RWLock, and
Semaphore. These primitives now have updated, more modernized apis:

* Guards are returned instead of locking with closures. All condition variables
  have moved inside the guards and extraneous methods have been removed.
* Downgrading on an rwlock is now done through the guard instead of the rwlock
  itself.

These types are meant to be general locks, not locks of an internal type (for
external usage). New types will be introduced for locking shared data.
2014-03-23 09:45:20 -07:00
Alex Crichton
53e451f410 sync: Move Once to using &self
Similarly to the rest of the previous commits, this moves the once primitive to
using &self instead of &mut self for proper sharing among many threads now.
2014-03-23 09:45:20 -07:00
Alex Crichton
3572a30e7a sync: Move the Mutex type to using &self
This also uses the Unsafe type for any interior mutability in the type to avoid
transmutes.
2014-03-23 09:45:20 -07:00
Alex Crichton
d6b3f1f231 sync: Move the concurrent queue to using &self
This commit also lifts it up a level in the module hierarchy in the soon-to-come
reorganization of libsync.
2014-03-23 09:45:19 -07:00
bors
cafb7ed6f6 auto merge of #13099 : FlaPer87/rust/master, r=huonw 2014-03-23 07:21:55 -07:00
bors
1cd0a5ed26 auto merge of #13093 : Havvy/rust/master, r=sfackler
This will make the types more readable in the documentation, since the letters correspond with what you should either be sending or expecting to receive.
2014-03-23 06:06:54 -07:00
Flavio Percoco
576e36e674 Register new snapshots 2014-03-23 11:37:31 +01:00
Ryan Scheel (Havvy)
f62bdfc134 Change types T,U to R (recv), S (sender) in libsync/comm.rs 2014-03-22 17:50:59 -07:00
Flavio Percoco
0169abd91d sync: Remove Freeze / NoFreeze 2014-03-22 15:47:33 +01:00
Huon Wilson
6d778ff610 Remove outdated and unnecessary std::vec_ng::Vec imports.
(And fix some tests.)
2014-03-22 01:08:57 +11:00
Patrick Walton
af79a5aa7d test: Make manual changes to deal with the fallout from removal of
`~[T]` in test, libgetopts, compiletest, librustdoc, and libnum.
2014-03-21 23:37:21 +11:00
Alex Crichton
11ac4df4d2 Register new snapshots 2014-03-20 11:02:26 -07:00
Alex Crichton
da3625161d Removing imports of std::vec_ng::Vec
It's now in the prelude.
2014-03-20 09:30:14 -07:00
Flavio Percoco
12ecafb31d Replace Freeze bounds with Share bounds 2014-03-20 10:16:55 +01:00
Daniel Micay
ce620320a2 rename std::vec -> std::slice
Closes #12702
2014-03-20 01:30:27 -04:00
Alex Crichton
0015cab1fd Test fixes and rebase conflicts
This commit switches over the backtrace infrastructure from piggy-backing off
the RUST_LOG environment variable to using the RUST_BACKTRACE environment
variable (logging is now disabled in libstd).
2014-03-15 22:56:46 -07:00
Alex Crichton
cc6ec8df95 log: Introduce liblog, the old std::logging
This commit moves all logging out of the standard library into an external
crate. This crate is the new crate which is responsible for all logging macros
and logging implementation. A few reasons for this change are:

* The crate map has always been a bit of a code smell among rust programs. It
  has difficulty being loaded on almost all platforms, and it's used almost
  exclusively for logging and only logging. Removing the crate map is one of the
  end goals of this movement.

* The compiler has a fair bit of special support for logging. It has the
  __log_level() expression as well as generating a global word per module
  specifying the log level. This is unfairly favoring the built-in logging
  system, and is much better done purely in libraries instead of the compiler
  itself.

* Initialization of logging is much easier to do if there is no reliance on a
  magical crate map being available to set module log levels.

* If the logging library can be written outside of the standard library, there's
  no reason that it shouldn't be. It's likely that we're not going to build the
  highest quality logging library of all time, so third-party libraries should
  be able to provide just as high-quality logging systems as the default one
  provided in the rust distribution.

With a migration such as this, the change does not come for free. There are some
subtle changes in the behavior of liblog vs the previous logging macros:

* The core change of this migration is that there is no longer a physical
  log-level per module. This concept is still emulated (it is quite useful), but
  there is now only a global log level, not a local one. This global log level
  is a reflection of the maximum of all log levels specified. The previously
  generated logging code looked like:

    if specified_level <= __module_log_level() {
        println!(...)
    }

  The newly generated code looks like:

    if specified_level <= ::log::LOG_LEVEL {
        if ::log::module_enabled(module_path!()) {
            println!(...)
        }
    }

  Notably, the first layer of checking is still intended to be "super fast" in
  that it's just a load of a global word and a compare. The second layer of
  checking is executed to determine if the current module does indeed have
  logging turned on.

  This means that if any module has a debug log level turned on, all modules
  with debug log levels get a little bit slower (they all do more expensive
  dynamic checks to determine if they're turned on or not).

  Semantically, this migration brings no change in this respect, but
  runtime-wise, this will have a perf impact on some code.

* A `RUST_LOG=::help` directive will no longer print out a list of all modules
  that can be logged. This is because the crate map will no longer specify the
  log levels of all modules, so the list of modules is not known. Additionally,
  warnings can no longer be provided if a malformed logging directive was
  supplied.

The new "hello world" for logging looks like:

    #[phase(syntax, link)]
    extern crate log;

    fn main() {
        debug!("Hello, world!");
    }
2014-03-15 22:26:36 -07:00
Steven Fackler
9106c15ffd Add rustdoc html crate info 2014-03-15 14:26:12 -07:00
bors
b35e8fbfcb auto merge of #12861 : huonw/rust/lint-owned-vecs, r=thestinger
lint: add lint for use of a `~[T]`.

This is useless at the moment (since pretty much every crate uses
`~[]`), but should help avoid regressions once completely removed from a
crate.
2014-03-13 22:26:35 -07:00
Huon Wilson
62792f09f2 lint: add lint for use of a ~[T].
This is useless at the moment (since pretty much every crate uses
`~[]`), but should help avoid regressions once completely removed from a
crate.
2014-03-14 11:28:39 +11:00
Alex Crichton
7858065113 std: Rename Chan/Port types and constructor
* Chan<T> => Sender<T>
* Port<T> => Receiver<T>
* Chan::new() => channel()
* constructor returns (Sender, Receiver) instead of (Receiver, Sender)
* local variables named `port` renamed to `rx`
* local variables named `chan` renamed to `tx`

Closes #11765
2014-03-13 13:23:29 -07:00
Huon Wilson
198caa87cd Update users for the std::rand -> librand move. 2014-03-12 11:31:43 +11:00
Kang Seonghoon
1c52c81846 fix typos with with repeated words, just like this sentence. 2014-03-06 20:19:14 +09:00
Palmer Cox
6d9bdf975a Rename all variables that have uppercase characters in their names to use only lowercase characters 2014-03-04 21:23:36 -05:00
Marvin Löbel
3158047a45 Cleaned up std::any
- Added `TraitObject` representation to `std::raw`.
- Added doc to `std::raw`.
- Removed `Any::as_void_ptr()` and `Any::as_mut_void_ptr()`
  methods as they are uneccessary now after the removal of
  headers on owned boxes. This reduces the number of virtual calls needed.
- Made the `..Ext` implementations work directly with the repr of
  a trait object.
- Removed `Any`-related traits from the prelude.

- Added bench for `Any`
2014-03-04 21:10:23 +01:00
Alex Crichton
02882fbd7e std: Change assert_eq!() to use {} instead of {:?}
Formatting via reflection has been a little questionable for some time now, and
it's a little unfortunate that one of the standard macros will silently use
reflection when you weren't expecting it. This adds small bits of code bloat to
libraries, as well as not always being necessary. In light of this information,
this commit switches assert_eq!() to using {} in the error message instead of
{:?}.

In updating existing code, there were a few error cases that I encountered:

* It's impossible to define Show for [T, ..N]. I think DST will alleviate this
  because we can define Show for [T].
* A few types here and there just needed a #[deriving(Show)]
* Type parameters needed a Show bound, I often moved this to `assert!(a == b)`
* `Path` doesn't implement `Show`, so assert_eq!() cannot be used on two paths.
  I don't think this is much of a regression though because {:?} on paths looks
  awful (it's a byte array).

Concretely speaking, this shaved 10K off a 656K binary. Not a lot, but sometime
significant for smaller binaries.
2014-02-28 23:01:54 -08:00
Huon Wilson
fbdd3b2ef6 sync: Rename arc::Condvar to arc::ArcCondvar.
The sync submodule also has a `Condvar` type, and its reexport was
shadowing the `arc` type, making it crate-private.
2014-03-01 00:11:56 +11:00
bors
a886549772 auto merge of #12336 : kballard/rust/mutexarc-no-freeze, r=alexcrichton
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.

Closes #9251.
2014-02-18 10:16:48 -08:00
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