about summary refs log tree commit diff
path: root/src/libstd/rt/uv
AgeCommit message (Collapse)AuthorLines
2013-10-29Register new snapshotsAlex Crichton-6734/+0
2013-10-29auto merge of #10058 : alexcrichton/rust/uv-crate, r=brsonbors-0/+6
This is one of the final steps needed to complete #9128. It still needs a little bit of polish before closing that issue, but it's in a pretty much "done" state now. The idea here is that the entire event loop implementation using libuv is now housed in `librustuv` as a completely separate library. This library is then injected (via `extern mod rustv`) into executable builds (similarly to how libstd is injected, tunable via `#[no_uv]`) to bring in the "rust blessed event loop implementation." Codegen-wise, there is a new `event_loop_factory` language item which is tagged on a function with 0 arguments returning `~EventLoop`. This function's symbol is then inserted into the crate map for an executable crate, and if there is no definition of the `event_loop_factory` language item then the value is null. What this means is that embedding rust as a library in another language just got a little harder. Libraries don't have crate maps, which means that there's no way to find the event loop implementation to spin up the runtime. That being said, it's always possible to build the runtime manually. This request also makes more runtime components public which should probably be public anyway. This new public-ness should allow custom scheduler setups everywhere regardless of whether you follow the `rt::start `path.
2013-10-29Move rust's uv implementation to its own crateAlex Crichton-0/+6
There are a few reasons that this is a desirable move to take: 1. Proof of concept that a third party event loop is possible 2. Clear separation of responsibility between rt::io and the uv-backend 3. Enforce in the future that the event loop is "pluggable" and replacable Here's a quick summary of the points of this pull request which make this possible: * Two new lang items were introduced: event_loop, and event_loop_factory. The idea of a "factory" is to define a function which can be called with no arguments and will return the new event loop as a trait object. This factory is emitted to the crate map when building an executable. The factory doesn't have to exist, and when it doesn't then an empty slot is in the crate map and a basic event loop with no I/O support is provided to the runtime. * When building an executable, then the rustuv crate will be linked by default (providing a default implementation of the event loop) via a similar method to injecting a dependency on libstd. This is currently the only location where the rustuv crate is ever linked. * There is a new #[no_uv] attribute (implied by #[no_std]) which denies implicitly linking to rustuv by default Closes #5019
2013-10-28Register new snapshotsAlex Crichton-8/+6
2013-10-28auto merge of #10093 : alexcrichton/rust/issue-8811, r=pcwaltonbors-0/+3
Closes #8811
2013-10-28auto merge of #10083 : alexcrichton/rust/timer-port, r=pcwaltonbors-1/+36
In addition to being able to sleep the current task, timers should be able to create ports which get notified after a period of time. Closes #10014
2013-10-28Allow fail messages to be caught, and introduce the Any traitMarvin Löbel-8/+11
Some code cleanup, sorting of import blocks Removed std::unstable::UnsafeArc's use of Either Added run-fail tests for the new FailWithCause impls Changed future_result and try to return Result<(), ~Any>. - Internally, there is an enum of possible fail messages passend around. - In case of linked failure or a string message, the ~Any gets lazyly allocated in future_results recv method. - For that, future result now returns a wrapper around a Port. - Moved and renamed task::TaskResult into rt::task::UnwindResult and made it an internal enum. - Introduced a replacement typedef `type TaskResult = Result<(), ~Any>`.
2013-10-27Ignore a test which never completes on windowsAlex Crichton-0/+1
I'm not entirely sure why this is happening, but the server task is never seeing the second send of the client task, and this test will very reliably fail to complete on windows.
2013-10-26Implement another error code found on windows.Alex Crichton-0/+3
Closes #8811
2013-10-26auto merge of #10070 : alexcrichton/rust/fewer-missiles, r=brsonbors-35/+41
This optimizes the `home_for_io` code path by requiring fewer scheduler operations in some situtations. When moving to your home scheduler, this no longer forces a context switch if you're already on the home scheduler. Instead, the homing code now simply pins you to your current scheduler (making it so you can't be stolen away). If you're not on your home scheduler, then we context switch away, sending you to your home scheduler. When the I/O operation is done, then we also no longer forcibly trigger a context switch. Instead, the action is cased on whether the task is homed or not. If a task does not have a home, then the task is re-flagged as not having a home and no context switch is performed. If a task is homed to the current scheduler, then we don't do anything, and if the task is homed to a foreign scheduler, then it's sent along its merry way. I verified that there are about a third as many `write` syscalls done in print operations now. Libuv uses write to implement async handles, and the homing before and after each I/O operation was triggering a write on these async handles. Additionally, using the terrible benchmark of printing 10k times in a loop, this drives the runtime from 0.6s down to 0.3s (yay!).
2013-10-25Enhance timers to create portsAlex Crichton-1/+36
In addition to being able to sleep the current task, timers should be able to create ports which get notified after a period of time. Closes #10014
2013-10-25Fire fewer homing missilesAlex Crichton-35/+41
This optimizes the `home_for_io` code path by requiring fewer scheduler operations in some situtations. When moving to your home scheduler, this no longer forces a context switch if you're already on the home scheduler. Instead, the homing code now simply pins you to your current scheduler (making it so you can't be stolen away). If you're not on your home scheduler, then we context switch away, sending you to your home scheduler. When the I/O operation is done, then we also no longer forcibly trigger a context switch. Instead, the action is cased on whether the task is homed or not. If a task does not have a home, then the task is re-flagged as not having a home and no context switch is performed. If a task is homed to the current scheduler, then we don't do anything, and if the task is homed to a foreign scheduler, then it's sent along its merry way. I verified that there are about a third as many `write` syscalls done in print operations now. Libuv uses write to implement async handles, and the homing before and after each I/O operation was triggering a write on these async handles. Additionally, using the terrible benchmark of printing 10k times in a loop, this drives the runtime from 0.6s down to 0.3s (yay!).
2013-10-25auto merge of #10060 : alexcrichton/rust/cached-stdout, r=brsonbors-3/+4
Almost all languages provide some form of buffering of the stdout stream, and this commit adds this feature for rust. A handle to stdout is lazily initialized in the Task structure as a buffered owned Writer trait object. The buffer behavior depends on where stdout is directed to. Like C, this line-buffers the stream when the output goes to a terminal (flushes on newlines), and also like C this uses a fixed-size buffer when output is not directed at a terminal. We may decide the fixed-size buffering is overkill, but it certainly does reduce write syscall counts when piping output elsewhere. This is a *huge* benefit to any code using logging macros or the printing macros. Formatting emits calls to `write` very frequently, and to have each of them backed by a write syscall was very expensive. In a local benchmark of printing 10000 lines of "what" to stdout, I got the following timings: when | terminal | redirected ----------|---------------|-------- before | 0.575s | 0.525s after | 0.197s | 0.013s C | 0.019s | 0.004s I can also confirm that we're buffering the output appropriately in both situtations. We're still far slower than C, but I believe much of that has to do with the "homing" that all tasks due, we're still performing an order of magnitude more write syscalls than C does.
2013-10-25Cache and buffer stdout per-task for printingAlex Crichton-3/+4
Almost all languages provide some form of buffering of the stdout stream, and this commit adds this feature for rust. A handle to stdout is lazily initialized in the Task structure as a buffered owned Writer trait object. The buffer behavior depends on where stdout is directed to. Like C, this line-buffers the stream when the output goes to a terminal (flushes on newlines), and also like C this uses a fixed-size buffer when output is not directed at a terminal. We may decide the fixed-size buffering is overkill, but it certainly does reduce write syscall counts when piping output elsewhere. This is a *huge* benefit to any code using logging macros or the printing macros. Formatting emits calls to `write` very frequently, and to have each of them backed by a write syscall was very expensive. In a local benchmark of printing 10000 lines of "what" to stdout, I got the following timings: when | terminal | redirected ---------------------------------- before | 0.575s | 0.525s after | 0.197s | 0.013s C | 0.019s | 0.004s I can also confirm that we're buffering the output appropriately in both situtations. We're still far slower than C, but I believe much of that has to do with the "homing" that all tasks due, we're still performing an order of magnitude more write syscalls than C does.
2013-10-24Remove the 'callback_ms' function from EventLoopAlex Crichton-9/+0
This is a peculiar function to require event loops to implement, and it's only used in one spot during tests right now. Instead, a possibly more robust apis for timers should be used rather than requiring all event loops to implement a curious-looking function.
2013-10-24Another round of test fixes and merge conflictsAlex Crichton-92/+86
2013-10-24Bring io::signal up to date with changes to rt::rtioAlex Crichton-44/+17
2013-10-24wrapping libuv signal for use in RustDo Nhat Minh-0/+175
descriptive names easier-to-use api reorganize and document
2013-10-24Migrate std::run to libuv processesAlex Crichton-6/+5
2013-10-24Test fixes and merge conflictsAlex Crichton-42/+59
2013-10-24Move stdin to using libuv's pipes instead of a ttyAlex Crichton-54/+29
I was seeing a lot of weird behavior with stdin behaving as a tty, and it doesn't really quite make sense, so instead this moves to using libuv's pipes instead (which make more sense for stdin specifically). This prevents piping input to rustc hanging forever.
2013-10-24Move as much I/O as possible off of native::ioAlex Crichton-44/+58
When uv's TTY I/O is used for the stdio streams, the file descriptors are put into a non-blocking mode. This means that other concurrent writes to the same stream can fail with EAGAIN or EWOULDBLOCK. By all I/O to event-loop I/O, we avoid this error. There is one location which cannot move, which is the runtime's dumb_println function. This was implemented to handle the EAGAIN and EWOULDBLOCK errors and simply retry again and again.
2013-10-24Migrate the last typedefs to ~Trait in rtioAlex Crichton-6/+6
There are no longer any remnants of typedefs, and everything is now built on true trait objects.
2013-10-24Don't attempt to export uv functions directlyAlex Crichton-30/+47
2013-10-24Remove IoFactoryObject for ~IoFactoryAlex Crichton-99/+110
This involved changing a fair amount of code, rooted in how we access the local IoFactory instance. I added a helper method to the rtio module to access the optional local IoFactory. This is different than before in which it was assumed that a local IoFactory was *always* present. Now, a separate io_error is raised when an IoFactory is not present, yet I/O is requested.
2013-10-24Remove rt::io::supportAlex Crichton-77/+54
This removes the PathLike trait associated with this "support module". This is yet another "container of bytes" trait, so I didn't want to duplicate what already exists throughout libstd. In actuality, we're going to pass of C strings to the libuv APIs, so instead the arguments are now bound with the 'ToCStr' trait instead. Additionally, a layer of complexity was removed by immediately converting these type-generic parameters into CStrings to get handed off to libuv apis.
2013-10-24Migrate Rtio objects to true trait objectsAlex Crichton-35/+38
This moves as many as I could over to ~Trait instead of ~Typedef. The only remaining one is the IoFactoryObject which should be coming soon...
2013-10-24Move rt::io::stdio from FileStream to a TTYAlex Crichton-148/+204
We get a little more functionality from libuv for these kinds of streams (things like terminal dimentions), and it also appears to more gracefully handle the stream being a window. Beforehand, if you used stdio and hit CTRL+d on a process, libuv would continually return 0-length successful reads instead of interpreting that the stream was closed. I was hoping to be able to write tests for this, but currently the testing infrastructure doesn't allow tests with a stdin and a stdout, but this has been manually tested! (not that it means much)
2013-10-24Remove unbound pipes from io::pipeAlex Crichton-10/+18
This isn't necessary for creating processes (or at least not right now), and it inherently attempts to expose implementation details.
2013-10-24Finish implementing io::net::addrinfoAlex Crichton-45/+117
This fills in the `hints` structure and exposes libuv's full functionality for doing dns lookups.
2013-10-24Implement io::net::unixAlex Crichton-66/+288
2013-10-23Made uv_stat_t.{st_dev, st_ino} public, #9958Ziad Hatahet-2/+2
2013-10-23Merge remote-tracking branch 'upstream/master'Ziad Hatahet-58/+58
2013-10-22Remove thread-blocking call to `libc::stat` in `Path::stat`Ziad Hatahet-0/+3
Fixes #9958
2013-10-23Making ai_next field publicreedlepee-1/+1
2013-10-23Removed Unnecessary comments and white spaces #4386reedlepee-45/+19
2013-10-23Making fields in std and extra : private #4386reedlepee-71/+97
2013-10-22Drop the '2' suffix from logging macrosAlex Crichton-2/+2
Who doesn't like a massive renaming?
2013-10-16auto merge of #9721 : klutzy/rust/uv-net-read-fix, r=alexcrichtonbors-2/+16
See #9605 for detailed information. This also fixes two tests of #8811.
2013-10-15path2: Adjust the API to remove all the _str mutation methodsKevin Ballard-12/+13
Add a new trait BytesContainer that is implemented for both byte vectors and strings. Convert Path::from_vec and ::from_str to one function, Path::new(). Remove all the _str-suffixed mutation methods (push, join, with_*, set_*) and modify the non-suffixed versions to use BytesContainer.
2013-10-15path2: Replace the path module outrightKevin Ballard-12/+14
Remove the old path. Rename path2 to path. Update all clients for the new path. Also make some miscellaneous changes to the Path APIs to help the adoption process.
2013-10-09option: rewrite the API to use compositionDaniel Micay-4/+4
2013-10-05std::rt: Add NotConnected to IoErrorKindklutzy-0/+3
2013-10-05std::rt::uv::net: Handle `read_start` errorklutzy-2/+13
cc #9605
2013-09-30std: Remove usage of fmt!Alex Crichton-24/+24
2013-09-30std::rt::uv::net: Enable tests on Win32klutzy-4/+0
Closes #8815.
2013-09-26std: removed some warnings in tests.Erick Tryzelaar-6/+5
2013-09-26std and rustc: Convert users of c_str to use .with_c_strErick Tryzelaar-8/+8
2013-09-24Stop accepting 'impl ...;', require {} insteadAlex Crichton-1/+1
Progress on #7981
2013-09-18Implement process bindings to libuvAlex Crichton-67/+652
This is a re-landing of #8645, except that the bindings are *not* being used to power std::run just yet. Instead, this adds the bindings as standalone bindings inside the rt::io::process module. I made one major change from before, having to do with how pipes are created/bound. It's much clearer now when you can read/write to a pipe, as there's an explicit difference (different types) between an unbound and a bound pipe. The process configuration now takes unbound pipes (and consumes ownership of them), and will return corresponding pipe structures back if spawning is successful (otherwise everything is destroyed normally).