summary refs log tree commit diff
path: root/src/libstd
AgeCommit message (Collapse)AuthorLines
2014-02-13Add some missing Show implementations in libstdBrendan Zabarauskas-1/+164
2014-02-12Expose whether event loops have active I/OAlex Crichton-0/+1
The green scheduler can optimize its runtime based on this by deciding to not go to sleep in epoll() if there is no active I/O and there is a task to be stolen. This is implemented for librustuv by keeping a count of the number of tasks which are currently homed. If a task is homed, and then performs a blocking I/O operation, the count will be nonzero while the task is blocked. The homing count is intentionally 0 when there are I/O handles, but no handles currently blocked. The reason for this is that epoll() would only be used to wake up the scheduler anyway. The crux of this change was to have a `HomingMissile` contain a mutable borrowed reference back to the `HomeHandle`. The rest of the change was just dealing with this fallout. This reference is used to decrement the homed handle count in a HomingMissile's destructor. Also note that the count maintained is not atomic because all of its increments/decrements/reads are all on the same I/O thread.
2014-02-12auto merge of #12204 : alexcrichton/rust/seek, r=pcwaltonbors-31/+80
This adopts the rules posted in #10432: 1. If a seek position is negative, then an error is generated 2. Seeks beyond the end-of-file are allowed. Future writes will fill the gap with data and future reads will return errors. 3. Seeks within the bounds of a file are fine. Closes #10432
2014-02-12Removed ty_type (previously used to represent *tydesc).Eduard Burtescu-0/+8
2014-02-11Finalize the Seek APIAlex Crichton-31/+80
This adopts the rules posted in #10432: 1. If a seek position is negative, then an error is generated 2. Seeks beyond the end-of-file are allowed. Future writes will fill the gap with data and future reads will return errors. 3. Seeks within the bounds of a file are fine. Closes #10432
2014-02-11Test fixes and rebase conflictsAlex Crichton-44/+31
2014-02-11Rewrite channels yet again for upgradeabilityAlex Crichton-643/+1853
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-11Shuffle around ownership in concurrent queuesAlex Crichton-340/+248
Beforehand, using a concurrent queue always mandated that the "shared state" be stored internally to the queues in order to provide a safe interface. This isn't quite as flexible as one would want in some circumstances, so instead this commit moves the queues to not containing the shared state. The queues no longer have a "default useful safe" interface, but rather a "default safe" interface (minus the useful part). The queues have to be shared manually through an Arc or some other means. This allows them to be a little more flexible at the cost of a usability hindrance. I plan on using this new flexibility to upgrade a channel to a shared channel seamlessly.
2014-02-11auto merge of #12158 : nikomatsakis/rust/issue-6801-borrowck-closures, ↵bors-77/+135
r=pcwalton I factored the commits by affected files, for the most part. The last 7 or 8 contain the meat of the PR. The rest are small changes to closures found in the codebase. Maybe interesting to read to see some of the impact of the rules. r? @pcwalton Fixes #6801
2014-02-11str -- borrow fields of self for use in closure since self.iter is borrowedNiko Matsakis-5/+7
2014-02-11io -- introduce local to avoid conflicting borrowNiko Matsakis-1/+2
2014-02-11vec -- introduce local var to make clear what subportion is being borrowedNiko Matsakis-2/+2
2014-02-11std -- replaces uses where const borrows would be requiredNiko Matsakis-70/+125
2014-02-11Fix broken link to the container guideSimon Sapin-1/+1
2014-02-11Move replace and swap to std::mem. Get rid of std::utilEdward Wang-210/+163
Also move Void to std::any, move drop to std::mem and reexport in prelude.
2014-02-10auto merge of #12149 : thomaslee/rust/ipaddr_deriving_iter_bytes, r=cmrbors-2/+13
This is a fairly trivial (but IMHO handy) change to implement IterBytes for IpAddr and SocketAddr. I originally stumbled across this because I wanted to use a SocketAddr as a HashMap key and discovered that I couldn't do it directly. Had to impl IterBytes on a new intermediate type to work around it.
2014-02-10IterBytes for IpAddr and SocketAddrTom Lee-2/+13
2014-02-09auto merge of #12143 : brson/rust/swap, r=alexcrichtonbors-28/+24
Thinking about swap as an example of unsafe programming. This cleans it up a bit. It also removes type parametrization over `RawPtr` from the memcpy functions to make this compile.
2014-02-09auto merge of #12136 : alexcrichton/rust/issue-12123, r=brsonbors-8/+10
Closes #12123
2014-02-09std: Clean up the swap function a littleBrian Anderson-8/+5
2014-02-09std: Stop parameterizing some memcpy functions over RawPtrBrian Anderson-23/+22
It unsafe assumptions that any impl of RawPtr is for actual pointers, that they can be copied by memcpy. Removing it is easy, so I don't think it's solving a real problem.
2014-02-09auto merge of #12124 : brson/rust/intrinsics, r=thestingerbors-55/+84
As mentioned https://github.com/mozilla/rust/pull/11956#issuecomment-34561655 I've taken some of the most commonly-used intrinsics and put them in a more logical place, reduced the amount of code looking in `unstable::intrinsics`. r? @thestinger
2014-02-09auto merge of #12120 : gifnksm/rust/buffered-chars, r=alexcrichtonbors-0/+45
Add `std::io::Chars` iterator and `Buffer#chars()` method
2014-02-09Fix the signature of CreateSymbolicLinkWAlex Crichton-8/+10
Closes #12123
2014-02-09std: Make mem's doc slightly more accurateBrian Anderson-1/+4
2014-02-09std: Move byteswap functions to memBrian Anderson-30/+34
2014-02-09std: Add move_val_init to mem. Replace direct intrinsic usageBrian Anderson-8/+15
2014-02-09std: Add init and uninit to mem. Replace direct intrinsic usageBrian Anderson-16/+31
2014-02-09std::io: Add `Chars` iterator for Buffer.gifnksm-0/+45
Add `std::io::Chars` iterator and `Buffer#chars()` method
2014-02-08Fix infinite loop in BufReader::read_until.Q.P.Liu-1/+9
2014-02-08Fix infinite loop in MemReader::read_until.Q.P.Liu-1/+9
2014-02-08auto merge of #12090 : bjz/rust/unimplemented, r=cmrbors-58/+81
Adds a standardised placeholder for marking unfinished code.
2014-02-08auto merge of #12109 : omasanori/rust/small-fixes, r=sfacklerbors-1/+1
Most of them are to reduce warnings in testing builds.
2014-02-08auto merge of #12098 : kballard/rust/from_utf8_lossy_tweak, r=huonwbors-342/+324
MaybeOwned allows from_utf8_lossy to avoid allocation if there are no invalid bytes in the input. Before: ``` test str::bench::from_utf8_lossy_100_ascii ... bench: 183 ns/iter (+/- 5) test str::bench::from_utf8_lossy_100_invalid ... bench: 341 ns/iter (+/- 15) test str::bench::from_utf8_lossy_100_multibyte ... bench: 227 ns/iter (+/- 13) test str::bench::from_utf8_lossy_invalid ... bench: 102 ns/iter (+/- 4) test str::bench::is_utf8_100_ascii ... bench: 2 ns/iter (+/- 0) test str::bench::is_utf8_100_multibyte ... bench: 2 ns/iter (+/- 0) ``` Now: ``` test str::bench::from_utf8_lossy_100_ascii ... bench: 96 ns/iter (+/- 4) test str::bench::from_utf8_lossy_100_invalid ... bench: 318 ns/iter (+/- 10) test str::bench::from_utf8_lossy_100_multibyte ... bench: 105 ns/iter (+/- 2) test str::bench::from_utf8_lossy_invalid ... bench: 105 ns/iter (+/- 2) test str::bench::is_utf8_100_ascii ... bench: 2 ns/iter (+/- 0) test str::bench::is_utf8_100_multibyte ... bench: 2 ns/iter (+/- 0) ```
2014-02-08auto merge of #12096 : brson/rust/morestack-addr, r=thestingerbors-3/+0
2014-02-07Rewrite path::Display to reduce unnecessary allocationKevin Ballard-44/+20
2014-02-07Delete send_str, rewrite clients on top of MaybeOwned<'static>Kevin Ballard-318/+240
Declare a `type SendStr = MaybeOwned<'static>` to ease readibility of types that needed the old SendStr behavior. Implement all the traits for MaybeOwned that SendStr used to implement.
2014-02-07Implement BytesContainer for MaybeOwnedKevin Ballard-0/+17
2014-02-07Tweak from_utf8_lossy to return a new MaybeOwned enumKevin Ballard-29/+96
MaybeOwned allows from_utf8_lossy to avoid allocation if there are no invalid bytes in the input.
2014-02-08Remove an unused variable in a test of std::c_str.OGINO Masanori-1/+0
Signed-off-by: OGINO Masanori <masanori.ogino@gmail.com>
2014-02-08Fix unused import warnings.OGINO Masanori-0/+1
Signed-off-by: OGINO Masanori <masanori.ogino@gmail.com>
2014-02-07auto merge of #12066 : huonw/rust/show2, r=alexcrichtonbors-90/+90
- Convert the formatting traits to `&self` rather than `_: &Self` - Rejig `syntax::ext::{format,deriving}` a little in preparation - Implement `#[deriving(Show)]`
2014-02-07auto merge of #12059 : thestinger/rust/glue, r=pcwaltonbors-26/+158
A follow-up from the work I started with 383e3fd13b99827b5dbb107da7433bd0a70dea80.
2014-02-08std::fmt: convert the formatting traits to a proper self.Huon Wilson-90/+90
Poly and String have polymorphic `impl`s and so require different method names.
2014-02-07rm out-of-date comment from std::unstable::rawDaniel Micay-3/+0
2014-02-07remove type descriptors from proc and @TDaniel Micay-23/+158
This also drops support for the managed pointer POISON_ON_FREE feature as it's not worth adding back the support for it. After a snapshot, the leftovers can be removed.
2014-02-07auto merge of #12029 : zkamsler/rust/merge-sort-allocations, r=huonwbors-5/+104
This pull request: 1) Changes the initial insertion sort to be in-place, and defers allocation of working set until merge is needed. 2) Increases the increases the maximum run length to use insertion sort for from 8 to 32 elements. This increases the size of vectors that will not allocate, and reduces the number of merge passes by two. It seemed to be the sweet spot in the benchmarks that I ran. Here are the results of some benchmarks. Note that they are sorting u64s, so types that are more expensive to compare or copy may have different behaviors. Before changes: ``` test vec::bench::sort_random_large bench: 719753 ns/iter (+/- 130173) = 111 MB/s test vec::bench::sort_random_medium bench: 4726 ns/iter (+/- 742) = 169 MB/s test vec::bench::sort_random_small bench: 344 ns/iter (+/- 76) = 116 MB/s test vec::bench::sort_sorted bench: 437244 ns/iter (+/- 70043) = 182 MB/s ``` Deferred allocation (8 element insertion sort): ``` test vec::bench::sort_random_large bench: 702630 ns/iter (+/- 88158) = 113 MB/s test vec::bench::sort_random_medium bench: 4529 ns/iter (+/- 497) = 176 MB/s test vec::bench::sort_random_small bench: 185 ns/iter (+/- 49) = 216 MB/s test vec::bench::sort_sorted bench: 425853 ns/iter (+/- 60907) = 187 MB/s ``` Deferred allocation (16 element insertion sort): ``` test vec::bench::sort_random_large bench: 692783 ns/iter (+/- 165837) = 115 MB/s test vec::bench::sort_random_medium bench: 4434 ns/iter (+/- 722) = 180 MB/s test vec::bench::sort_random_small bench: 187 ns/iter (+/- 38) = 213 MB/s test vec::bench::sort_sorted bench: 393783 ns/iter (+/- 85548) = 203 MB/s ``` Deferred allocation (32 element insertion sort): ``` test vec::bench::sort_random_large bench: 682556 ns/iter (+/- 131008) = 117 MB/s test vec::bench::sort_random_medium bench: 4370 ns/iter (+/- 1369) = 183 MB/s test vec::bench::sort_random_small bench: 179 ns/iter (+/- 32) = 223 MB/s test vec::bench::sort_sorted bench: 358353 ns/iter (+/- 65423) = 223 MB/s ``` Deferred allocation (64 element insertion sort): ``` test vec::bench::sort_random_large bench: 712040 ns/iter (+/- 132454) = 112 MB/s test vec::bench::sort_random_medium bench: 4425 ns/iter (+/- 784) = 180 MB/s test vec::bench::sort_random_small bench: 179 ns/iter (+/- 81) = 223 MB/s test vec::bench::sort_sorted bench: 317812 ns/iter (+/- 62675) = 251 MB/s ``` This is the best I could manage with the basic merge sort while keeping the invariant that the original vector must contain each element exactly once when the comparison function is called. If one is not married to a stable sort, an in-place n*log(n) sorting algorithm may have better performance in some cases. for #12011 cc @huonw
2014-02-07Reduced allocations in merge_sort for short vectorsZach Kamsler-5/+104
Added a seperate in-place insertion sort for short vectors. Increased threshold for insertion short for 8 to 32 elements for small types and 16 for larger types. Added benchmarks for sorting larger types.
2014-02-07rustc: Remove 'morestack_addr' intrinsic. UnusedBrian Anderson-3/+0
2014-02-08Clean up formatting in macros moduleBrendan Zabarauskas-58/+74