about summary refs log tree commit diff
path: root/src/libstd/rt
AgeCommit message (Collapse)AuthorLines
2013-08-06Merge commit 'd89ff7eef969aee6b493bc846b64d68358fafbcd' into ↵Erick Tryzelaar-63/+104
remove-str-trailing-nulls
2013-08-06auto merge of #8317 : bblum/rust/fast-spawn-unlinked, r=brsonbors-5/+8
This lazily initializes the taskgroup structs for ```spawn_unlinked``` tasks. If such a task never spawns another task linked to it (or a descendant of it), its taskgroup is simply never initialized at all. Also if an unlinked task spawns another unlinked task, neither of them will need to initialize their taskgroups. This works for the main task too. I benchmarked this with the following test case and observed a ~~21% speedup (average over 4 runs: 7.85 sec -> 6.20 sec, 2.5 GHz)~~ 11% speedup, see comment below. ``` use std::task; use std::cell::Cell; use std::rt::comm; static NUM: uint = 1024*256; fn run(f: ~fn()) { let mut t = task::task(); t.unlinked(); t.spawn(f); } fn main() { do NUM.times { let (p,c) = comm::oneshot(); let c = Cell::new(c); do run { c.take().send(()); } p.recv(); } } ```
2013-08-06Use FromStr for IpAddr in rt::uv::netStepan Koltsov-70/+2
2013-08-06auto merge of #8313 : msullivan/rust/cleanup, r=catamorphismbors-1/+1
2013-08-06Implement FromStr for IpAddr and SocketAddrStepan Koltsov-0/+365
Better than that in rt::uv::net, because it: * handles invalid input explicitly, without fail!() * parses socket address, not just IP * handles various ipv4-in-ipv6 addresses, like 2001:db8:122:344::192.0.2.33 (see http://tools.ietf.org/html/rfc6052 for example) * rejects output like `127.0000000.0.1` * does not allocate heap memory * have unit tests
2013-08-05Lazily initialize 'leaf node' taskgroups for unlinked spawns, for an ↵Ben Blum-0/+4
apparent 11% speedup.
2013-08-05(cleanup) Uncomment an assertion that now holds.Ben Blum-5/+4
2013-08-05Updated std::Option, std::Either and std::ResultMarvin Löbel-13/+47
- Made naming schemes consistent between Option, Result and Either - Changed Options Add implementation to work like the maybe monad (return None if any of the inputs is None) - Removed duplicate Option::get and renamed all related functions to use the term `unwrap` instead
2013-08-05Get rid of some NOTEs.Michael Sullivan-1/+1
2013-08-05auto merge of #8303 : brson/rust/tls-magic-wtf, r=brsonbors-0/+13
2013-08-05std::rt: Use magic to make TLS work from annihilated boxes. #8302Brian Anderson-0/+13
2013-08-04std::rt: Schedule more scheduler callbacks to avoid dropping messagesBrian Anderson-1/+3
2013-08-04std: Fix newsched logging truncationBrian Anderson-4/+17
The truncation needs to be done in the console logger in order to catch all the logging output, and because truncation only matters when outputting to the console.
2013-08-04Merge remote-tracking branch 'remotes/origin/master' into str-remove-nullErick Tryzelaar-206/+195
2013-08-04std::rt: Remove the test for context()Brian Anderson-10/+0
This is no longer testable once newsched is turned on
2013-08-04std::rt: Don't allow schedulers to exit before handling all messagesBrian Anderson-0/+10
Every time run_sched_once performs a 'scheduling action' it needs to guarantee that it runs at least one more time, so enqueue another run_sched_once callback. The primary reason it needs to do this is because not all async callbacks are guaranteed to run, it's only guaranteed that *a* callback will run after enqueing one - some may get dropped. At the moment this means we wastefully create lots of callbacks to ensure that there will *definitely* be a callback queued up to continue running the scheduler. The logic really needs to be tightened up here.
2013-08-04std::rt: 3MB stacks!Brian Anderson-2/+2
rustc needs *even more* megabytes when run without optimizations
2013-08-04std::rt: Run the tests for Local in a bare threadBrian Anderson-36/+45
Otherwise interferes with the existing runtime
2013-08-04std::rt: Improve the error message when the thread-local ptr is nullBrian Anderson-11/+15
Also fix some incorrect comments and variable names.
2013-08-04std: replace str::as_c_str with std::c_strErick Tryzelaar-20/+22
2013-08-04std: minor cleanupErick Tryzelaar-3/+3
2013-08-04auto merge of #8243 : stepancheg/rust/ipv, r=brsonbors-148/+142
multicast functions now take IpAddr (without port), because they dont't need port. Uv* types renamed: * UvIpAddr -> UvSocketAddr * UvIpv4 -> UvIpv4SocketAddr * UvIpv6 -> UvIpv6SocketAddr "Socket address" is a common name for (ip-address, port) pair (e.g. in sockaddr_in struct). P. S. Are there any backward compatibility concerns? What is std::rt module, is it a part of public API?
2013-08-03auto merge of #8264 : thestinger/rust/snapshot, r=Aatchbors-31/+31
2013-08-03remove obsolete `foreach` keywordDaniel Micay-31/+31
this has been replaced by `for`
2013-08-03std::rt: Run local storage cleanup and the box annihilator inside the try/catchBrian Anderson-27/+22
And before collect_failure. These are both running user dtors and need to be handled in the task try/catch block and before the final task cleanup code.
2013-08-03auto merge of #8213 : kballard/rust/fd-limit, r=brsonbors-4/+83
Revert the workaround 49b72bd and instead bump the fd limit on OS X.
2013-08-02librustc: Disallow "unsafe" for external functionsPatrick Walton-4/+4
2013-08-02Bump fd limit on macos when running rt testsKevin Ballard-0/+78
OS X defaults the ulimit for open files to 256 for programs launched from the Terminal (GUI apps get a higher default). Unfortunately this is too low for the rt tests, which deliberately overcommit and create a lot of threads (which means a lot of schedulers, and each scheduler needs at least 2 fds). By calling sysctl() and setrlimit() we can bump the fd limit up to the maximum allowed (on stock OS X it's 10240). Fixes #7772.
2013-08-02Revert "std::rt: Use a constant 4 threads for multithreaded sched tests"Kevin Ballard-4/+5
This workaround was less than ideal. A better solution is to raise the fd limit. This reverts commit 49b72bdd77916e27aaf95909516702c1450f11ac.
2013-08-03Rename IpAddr -> SocketAddr, extract IpAddr from SocketAddrStepan Koltsov-148/+142
multicast functions now take IpAddr (without port), because they dont't need port. Uv* types renamed: * UvIpAddr -> UvSocketAddr * UvIpv4 -> UvIpv4SocketAddr * UvIpv6 -> UvIpv6SocketAddr "Socket address" is a common name for (ip-address, port) pair (e.g. in sockaddr_in struct).
2013-08-02Add an assert_may_sleep() check on every context switch.Ben Blum-0/+4
2013-08-02Don't fail from kill signals if already unwinding.Ben Blum-3/+3
2013-08-02Fix embarrassing bug where 'unkillable' would unwind improperly when it ↵Ben Blum-2/+3
receives a kill signal.
2013-08-02Fix nasty double-free bug where a newrt chan could get killed after ↵Ben Blum-2/+7
rescheduling but before suppressing_finalize.
2013-08-02Add SendDeferred trait and use it to fix #8214.Ben Blum-24/+127
2013-08-02auto merge of #8221 : brson/rust/single-threaded, r=graydonbors-3/+9
This is the last major runtime feature needed for the transition to the new scheduler.
2013-08-02auto merge of #8195 : bblum/rust/task-cleanup, r=brsonbors-23/+90
In the first commit it is obvious why some of the barriers can be changed to ```Relaxed```, but it is not as obvious for the once I changed in ```kill.rs```. The rationale for those is documented as part of the documenting commit. Also the last commit is a temporary hack to prevent kill signals from being received in taskgroup cleanup code, which could be fixed in a more principled way once the old runtime is gone.
2013-08-02std: Implement SingleThreaded spawn mode for newschedBrian Anderson-3/+9
2013-08-02replace `range` with an external iteratorDaniel Micay-25/+23
2013-08-01modified local to include an implementation for try_unsafe_borrow::<Task> so ↵toddaaro-4/+11
that the log methods will work
2013-08-01fixed incorrect handling of returned scheduler option and restructed ↵toddaaro-75/+64
scheduler functions slightly
2013-08-01minor tweaks - unboxed the coroutine so that it is no longer a ~ pointer ↵toddaaro-32/+72
inside the task struct, and also added an assert to verify that send is never called inside scheduler context as it is undefined (BROKEN) if that happens
2013-08-01Fixed a race where a scheduler configured to only run tasks pinned to it ↵toddaaro-8/+35
would "bounch" a regular task in and out of the work queue without allowing a different scheduler to run it.
2013-08-01A major refactoring that changes the way the runtime uses TLS. In thetoddaaro-987/+867
old design the TLS held the scheduler struct, and the scheduler struct held the active task. This posed all sorts of weird problems due to how we wanted to use the contents of TLS. The cleaner approach is to leave the active task in TLS and have the task hold the scheduler. To make this work out the scheduler has to run inside a regular task, and then once that is the case the context switching code is massively simplified, as instead of three possible paths there is only one. The logical flow is also easier to follow, as the scheduler struct acts somewhat like a "token" indicating what is active. These changes also necessitated changing a large number of runtime tests, and rewriting most of the runtime testing helpers. Polish level is "low", as I will very soon start on more scheduler changes that will require wiping the polish off. That being said there should be sufficient comments around anything complex to make this entirely respectable as a standalone commit.
2013-08-01Temporary workaround to prevent taskgroup cleanup code from failing without ↵Ben Blum-3/+13
an exception handler.
2013-08-01Make a forgotten assert in comm be cfg(test)-dependentBen Blum-3/+1
2013-08-01Document task killing design and relaxed barrier rationale.Ben Blum-1/+57
2013-08-01Relax some atomic barriers. Loosen up all that tension. There, doesn't that ↵Ben Blum-16/+19
feel good?
2013-08-01migrate to foreachDaniel Micay-2/+2
2013-08-01std: Change `Times` trait to use `do` instead of `for`blake2-ppc-27/+27
Change the former repetition:: for 5.times { } to:: do 5.times { } .times() cannot be broken with `break` or `return` anymore; for those cases, use a numerical range loop instead.