about summary refs log tree commit diff
path: root/src/libstd/rt
AgeCommit message (Collapse)AuthorLines
2014-02-23std: Move unstable::stack to rt::stackBrian Anderson-3/+282
2014-02-23std: Remove unstable::langBrian Anderson-1/+36
Put the lonely lang items here closer to the code they are calling.
2014-02-23std: Move raw to std::rawBrian Anderson-3/+3
Issue #1457
2014-02-23std: Move intrinsics to std::intrinsics.Brian Anderson-3/+3
Issue #1457
2014-02-23Move std::{trie, hashmap} to libcollectionsAlex Crichton-19/+24
These two containers are indeed collections, so their place is in libcollections, not in libstd. There will always be a hash map as part of the standard distribution of Rust, but by moving it out of the standard library it makes libstd that much more portable to more platforms and environments. This conveniently also removes the stuttering of 'std::hashmap::HashMap', although 'collections::HashMap' is only one character shorter.
2014-02-20move extra::test to libtestLiigo Zhuang-2/+4
2014-02-18Spellcheck library docs.Huon Wilson-2/+2
2014-02-15auto merge of #12235 : huonw/rust/raii-lock, r=alexcrichtonbors-13/+6
- 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-16std: Rename unstable::mutex::Mutex to StaticNativeMutex.Huon Wilson-2/+2
This better reflects its purpose and design.
2014-02-16std: add an RAII unlocker to Mutex.Huon Wilson-11/+4
This automatically unlocks its lock when it goes out of scope, and provides a safe(ish) method to call .wait.
2014-02-15auto merge of #12272 : alexcrichton/rust/snapshot, r=kballardbors-14/+0
This notably contains the `extern mod` => `extern crate` change. Closes #9880
2014-02-15auto merge of #12283 : kballard/rust/env-args-bytes, r=ericktbors-21/+23
Change `os::args()` and `os::env()` to use `str::from_utf8_lossy()`. Add new functions `os::args_as_bytes()` and `os::env_as_bytes()` to retrieve the args/env as byte vectors instead. The existing methods were left returning strings because I expect that the common use-case is to want string handling. Fixes #7188.
2014-02-14Register new snapshotsAlex Crichton-14/+0
This enables the parser error for `extern mod` => `extern crate` transitions.
2014-02-14Use str::from_utf8_lossy() in os::args(), add os::args_as_bytes()Kevin Ballard-21/+23
os::args() was using str::raw::from_c_str(), which would assert if the C-string wasn't valid UTF-8. Switch to using from_utf8_lossy() instead, and add a separate function os::args_as_bytes() that returns the ~[u8] byte-vectors instead.
2014-02-14auto merge of #12267 : alexcrichton/rust/rollup, r=alexcrichtonbors-2/+2
The last commit has the closed PRs
2014-02-14Invoke gcc with -nodefaultlibsAlex Crichton-0/+10
This will hopefully bring us closer to #11937. We're still using gcc's idea of "startup files", but this should prevent us from leaking in dependencies that we don't quite want (libgcc for example once compiler-rt is what we use).
2014-02-14return value/use extra::test::black_box in benchmarkslpy-2/+2
2014-02-14auto merge of #12186 : alexcrichton/rust/no-sleep-2, r=brsonbors-0/+1
Any single-threaded task benchmark will spend a good chunk of time in `kqueue()` on osx and `epoll()` on linux, and the reason for this is that each time a task is terminated it will hit the syscall. When a task terminates, it context switches back to the scheduler thread, and the scheduler thread falls out of `run_sched_once` whenever it figures out that it did some work. If we know that `epoll()` will return nothing, then we can continue to do work locally (only while there's work to be done). We must fall back to `epoll()` whenever there's active I/O in order to check whether it's ready or not, but without that (which is largely the case in benchmarks), we can prevent the costly syscall and can get a nice speedup. I've separated the commits into preparation for this change and then the change itself, the last commit message has more details.
2014-02-13Don't require an allocation for on_exit messagesAlex Crichton-4/+12
Instead, use an enum to allow running both a procedure and sending the task result over a channel. I expect the common case to be sending on a channel (e.g. task::try), so don't require an extra allocation in the common case. cc #11389
2014-02-13Don't allocate in LocalHeap::new()Alex Crichton-7/+8
One of these is allocated for every task, trying to cut down on allocations cc #11389
2014-02-13Register new snapshotsAlex Crichton-103/+1
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-11Rewrite channels yet again for upgradeabilityAlex Crichton-3/+5
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-11Move replace and swap to std::mem. Get rid of std::utilEdward Wang-6/+6
Also move Void to std::any, move drop to std::mem and reexport in prelude.
2014-02-09std: Add init and uninit to mem. Replace direct intrinsic usageBrian Anderson-3/+3
2014-02-07Delete send_str, rewrite clients on top of MaybeOwned<'static>Kevin Ballard-1/+1
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-07remove type descriptors from proc and @TDaniel Micay-2/+88
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-06Remove std::conditionAlex Crichton-1/+0
This has been a long time coming. Conditions in rust were initially envisioned as being a good alternative to error code return pattern. The idea is that all errors are fatal-by-default, and you can opt-in to handling the error by registering an error handler. While sounding nice, conditions ended up having some unforseen shortcomings: * Actually handling an error has some very awkward syntax: let mut result = None; let mut answer = None; io::io_error::cond.trap(|e| { result = Some(e) }).inside(|| { answer = Some(some_io_operation()); }); match result { Some(err) => { /* hit an I/O error */ } None => { let answer = answer.unwrap(); /* deal with the result of I/O */ } } This pattern can certainly use functions like io::result, but at its core actually handling conditions is fairly difficult * The "zero value" of a function is often confusing. One of the main ideas behind using conditions was to change the signature of I/O functions. Instead of read_be_u32() returning a result, it returned a u32. Errors were notified via a condition, and if you caught the condition you understood that the "zero value" returned is actually a garbage value. These zero values are often difficult to understand, however. One case of this is the read_bytes() function. The function takes an integer length of the amount of bytes to read, and returns an array of that size. The array may actually be shorter, however, if an error occurred. Another case is fs::stat(). The theoretical "zero value" is a blank stat struct, but it's a little awkward to create and return a zero'd out stat struct on a call to stat(). In general, the return value of functions that can raise error are much more natural when using a Result as opposed to an always-usable zero-value. * Conditions impose a necessary runtime requirement on *all* I/O. In theory I/O is as simple as calling read() and write(), but using conditions imposed the restriction that a rust local task was required if you wanted to catch errors with I/O. While certainly an surmountable difficulty, this was always a bit of a thorn in the side of conditions. * Functions raising conditions are not always clear that they are raising conditions. This suffers a similar problem to exceptions where you don't actually know whether a function raises a condition or not. The documentation likely explains, but if someone retroactively adds a condition to a function there's nothing forcing upstream users to acknowledge a new point of task failure. * Libaries using I/O are not guaranteed to correctly raise on conditions when an error occurs. In developing various I/O libraries, it's much easier to just return `None` from a read rather than raising an error. The silent contract of "don't raise on EOF" was a little difficult to understand and threw a wrench into the answer of the question "when do I raise a condition?" Many of these difficulties can be overcome through documentation, examples, and general practice. In the end, all of these difficulties added together ended up being too overwhelming and improving various aspects didn't end up helping that much. A result-based I/O error handling strategy also has shortcomings, but the cognitive burden is much smaller. The tooling necessary to make this strategy as usable as conditions were is much smaller than the tooling necessary for conditions. Perhaps conditions may manifest themselves as a future entity, but for now we're going to remove them from the standard library. Closes #9795 Closes #8968
2014-02-05Implement clone() for TCP/UDP/Unix socketsAlex Crichton-0/+4
This is part of the overall strategy I would like to take when approaching issue #11165. The only two I/O objects that reasonably want to be "split" are the network stream objects. Everything else can be "split" by just creating another version. The initial idea I had was the literally split the object into a reader and a writer half, but that would just introduce lots of clutter with extra interfaces that were a little unnnecssary, or it would return a ~Reader and a ~Writer which means you couldn't access things like the remote peer name or local socket name. The solution I found to be nicer was to just clone the stream itself. The clone is just a clone of the handle, nothing fancy going on at the kernel level. Conceptually I found this very easy to wrap my head around (everything else supports clone()), and it solved the "split" problem at the same time. The cloning support is pretty specific per platform/lib combination: * native/win32 - uses some specific WSA apis to clone the SOCKET handle * native/unix - uses dup() to get another file descriptor * green/all - This is where things get interesting. When we support full clones of a handle, this implies that we're allowing simultaneous writes and reads to happen. It turns out that libuv doesn't support two simultaneous reads or writes of the same object. It does support *one* read and *one* write at the same time, however. Some extra infrastructure was added to just block concurrent writers/readers until the previous read/write operation was completed. I've added tests to the tcp/unix modules to make sure that this functionality is supported everywhere.
2014-02-03std: Remove try_send_deferred plus all falloutAlex Crichton-3/+10
Now that extra::sync primitives are built on a proper mutex instead of a pthreads one, there's no longer any use for this function.
2014-02-03std: Remove io::io_errorAlex Crichton-24/+18
* All I/O now returns IoResult<T> = Result<T, IoError> * All formatting traits now return fmt::Result = IoResult<()> * The if_ok!() macro was added to libstd
2014-02-02std,extra: remove use of & support for @[].Huon Wilson-1/+1
2014-01-31auto merge of #11885 : bnoordhuis/rust/issue11694, r=alexcrichtonbors-5/+89
EINVAL means that the requested stack size is either not a multiple of the system page size or that it's smaller than PTHREAD_STACK_MIN. Figure out what the case is, fix it up and retry. If it still fails, give up, like before. Suggestions for future improvements: * don't fail!() but instead signal a condition, or * silently ignore the error and use a default sized stack. Fixes #11694. The first two commits put the framework in place, the third one contains the meat.
2014-01-31Use __pthread_get_minstack() when available.Ben Noordhuis-1/+46
glibc >= 2.15 has a __pthread_get_minstack() function that returns PTHREAD_STACK_MIN plus however many bytes are needed for thread-local storage. Use it when it's available because just PTHREAD_STACK_MIN is not enough in applications that have big thread-local storage requirements. Fixes #6233.
2014-01-31Retry on EINVAL from pthread_attr_setstacksize()Ben Noordhuis-5/+44
Enforce that the stack size is > RED_ZONE + PTHREAD_STACK_MIN. If the call to pthread_attr_setstacksize() subsequently fails with EINVAL, it means that the platform requires the stack size to be a multiple of the page size. In that case, round up to the nearest page and retry. Fixes #11694.
2014-01-31auto merge of #11918 : omasanori/rust/reduce-warnings, r=alexcrichtonbors-1/+1
Moving forward to green waterfall.
2014-01-30Fix the size of the _Unwind_Exception structAlex Crichton-1/+4
On OSX 32-bit, the private fields are 5 words long, not 2. I found this segfaulting before this change, and after this change it no longer segfaulted.
2014-01-29Remove seldom-used std::reference functions.xales-2/+1
2014-01-29Rename std::borrow to std::reference.xales-2/+2
Fixes #11814
2014-01-30Append ; to #[allow(dead_code)].OGINO Masanori-1/+1
Signed-off-by: OGINO Masanori <masanori.ogino@gmail.com>
2014-01-29Removing do keyword from libstd and librustcScott Lawrence-14/+13
2014-01-28std: comment about OOM & allocs in begin_unwind_fmt.Huon Wilson-0/+4
Follow-up to #11841 which added this function.
2014-01-27std: add begin_unwind_fmt that reduces codesize for formatted fail!().Huon Wilson-1/+13
This ends up saving a single `call` instruction in the optimised code, but saves a few hundred lines of non-optimised IR for `fn main() { fail!("foo {}", "bar"); }` (comparing against the minimal generic baseline from the parent commit).
2014-01-27std: reduce the generic code instantiated by fail!().Huon Wilson-3/+18
This splits the vast majority of the code path taken by `fail!()` (`begin_unwind`) into a separate non-generic inline(never) function, so that uses of `fail!()` only monomorphise a small amount of code, reducing code bloat and making very small crates compile faster.
2014-01-26Removed all instances of XXX in preparation for relaxing of FIXME ruleSalem Talha-11/+11
2014-01-26auto merge of #11762 : alexcrichton/rust/guard_pages, r=alexcrichtonbors-2/+13
Rebasing of the previous PRs, I believe I've found the problems.
2014-01-25auto merge of #11790 : lfairy/rust/rename-num-consts, r=alexcrichtonbors-2/+2
The following are renamed: * `min_value` => `MIN` * `max_value` => `MAX` * `bits` => `BITS` * `bytes` => `BYTES` All tests pass, except for `run-pass/phase-syntax-link-does-resolve.rs`. I doubt that failure is related, though. Fixes #10010.
2014-01-25Uppercase numeric constantsChris Wong-2/+2
The following are renamed: * `min_value` => `MIN` * `max_value` => `MAX` * `bits` => `BITS` * `bytes` => `BYTES` Fixes #10010.
2014-01-25Fix some docs about rtDerek Chiang-3/+1
2014-01-24Use `mmap` to map in task stacks and guard pageCorey Richardson-2/+13
Also implement caching of stacks.