summary refs log tree commit diff
path: root/src/libstd/rt/rtio.rs
AgeCommit message (Collapse)AuthorLines
2013-12-25Test fixes and rebase conflictsAlex Crichton-8/+10
* vec::raw::to_ptr is gone * Pausible => Pausable * Removing @ * Calling the main task "<main>" * Removing unused imports * Removing unused mut * Bringing some libextra tests up to date * Allowing compiletest to work at stage0 * Fixing the bootstrap-from-c rmake tests * assert => rtassert in a few cases * printing to stderr instead of stdout in fail!()
2013-12-24rustuv: Remove the id() function from IoFactoryAlex Crichton-2/+0
The only user of this was the homing code in librustuv, and it just manually does the cast from a pointer to a uint now.
2013-12-24green: Rip the bandaid off, introduce libgreenAlex Crichton-4/+7
This extracts everything related to green scheduling from libstd and introduces a new libgreen crate. This mostly involves deleting most of std::rt and moving it to libgreen. Along with the movement of code, this commit rearchitects many functions in the scheduler in order to adapt to the fact that Local::take now *only* works on a Task, not a scheduler. This mostly just involved threading the current green task through in a few locations, but there were one or two spots where things got hairy. There are a few repercussions of this commit: * tube/rc have been removed (the runtime implementation of rc) * There is no longer a "single threaded" spawning mode for tasks. This is now encompassed by 1:1 scheduling + communication. Convenience methods have been introduced that are specific to libgreen to assist in the spawning of pools of schedulers.
2013-12-24std: Expose that LocalIo may not always be availableAlex Crichton-23/+37
It is not the case that all programs will always be able to acquire an instance of the LocalIo borrow, so this commit exposes this limitation by returning Option<LocalIo> from LocalIo::borrow(). At the same time, a helper method LocalIo::maybe_raise() has been added in order to encapsulate the functionality of raising on io_error if there is on local I/O available.
2013-12-16Fallout of rewriting std::commAlex Crichton-2/+2
2013-12-15std::rt: s/pausible/pausable/.Huon Wilson-2/+2
2013-12-10libstd: Remove `Cell` from the library.Patrick Walton-8/+15
2013-12-10librustuv: Change `with_local_io` to use RAII.Patrick Walton-23/+48
2013-11-19libstd: Change all uses of `&fn(A)->B` over to `|A|->B` in libstdPatrick Walton-2/+2
2013-11-18Allow piped stdout/stderr use uv_tty_tAlex Crichton-0/+1
There are issues with reading stdin when it is actually attached to a pipe, but I have run into no problems in writing to stdout/stderr when they are attached to pipes.
2013-11-13Implement native::IoFactoryAlex Crichton-9/+17
This commit re-organizes the io::native module slightly in order to have a working implementation of rtio::IoFactory which uses native implementations. The goal is to seamlessly multiplex among libuv/native implementations wherever necessary. Right now most of the native I/O is unimplemented, but we have existing bindings for file descriptors and processes which have been hooked up. What this means is that you can now invoke println!() from libstd with no local task, no local scheduler, and even without libuv. There's still plenty of work to do on the native I/O factory, but this is the first steps into making it an official portion of the standard library. I don't expect anyone to reach into io::native directly, but rather only std::io primitives will be used. Each std::io interface seamlessly falls back onto the native I/O implementation if the local scheduler doesn't have a libuv one (hurray trait ojects!)
2013-11-11Move std::rt::io to std::ioAlex Crichton-12/+12
2013-11-12Implemented a ProcessExit enum and helper methods to std::rt::io::process ↵Matthew Iselin-2/+2
for getting process termination status, or the signal that terminated a process. A test has been added to rtio-processes.rs to ensure signal termination is picked up correctly.
2013-11-10Fall back from uv tty instances more aggressivelyAlex Crichton-1/+0
It appears that uv's support for interacting with a stdio stream as a tty when it's actually a pipe is pretty problematic. To get around this, promote a check to see if the stream is a tty to the top of the tty constructor, and bail out quickly if it's not identified as a tty. Closes #10237
2013-11-10Rework the idle callback to have a safer interfaceAlex Crichton-3/+1
It turns out that the uv implementation would cause use-after-free if the idle callback was used after the call to `close`, and additionally nothing would ever really work that well if `start()` were called twice. To change this, the `start` and `close` methods were removed in favor of specifying the callback at creation, and allowing destruction to take care of closing the watcher.
2013-11-10Add bindings to uv's utime functionAlex Crichton-0/+2
This exposes the ability to change the modification and access times on a file. Closes #10266
2013-11-10Start migrating stream I/O away from ~fn()Alex Crichton-2/+0
2013-11-10Remove usage of ~fn() from uv async/idleAlex Crichton-3/+7
2013-11-03Fill out the remaining functionality in io::fileAlex Crichton-5/+18
This adds bindings to the remaining functions provided by libuv, all of which are useful operations on files which need to get exposed somehow. Some highlights: * Dropped `FileReader` and `FileWriter` and `FileStream` for one `File` type * Moved all file-related methods to be static methods under `File` * All directory related methods are still top-level functions * Created `io::FilePermission` types (backed by u32) that are what you'd expect * Created `io::FileType` and refactored `FileStat` to use FileType and FilePermission * Removed the expanding matrix of `FileMode` operations. The mode of reading a file will not have the O_CREAT flag, but a write mode will always have the O_CREAT flag. Closes #10130 Closes #10131 Closes #10121
2013-11-03Remove all blocking std::os blocking functionsAlex Crichton-2/+5
This commit moves all thread-blocking I/O functions from the std::os module. Their replacements can be found in either std::rt::io::file or in a hidden "old_os" module inside of native::file. I didn't want to outright delete these functions because they have a lot of special casing learned over time for each OS/platform, and I imagine that these will someday get integrated into a blocking implementation of IoFactory. For now, they're moved to a private module to prevent bitrot and still have tests to ensure that they work. I've also expanded the extensions to a few more methods defined on Path, most of which were previously defined in std::os but now have non-thread-blocking implementations as part of using the current IoFactory. The api of io::file is in flux, but I plan on changing it in the next commit as well. Closes #10057
2013-11-03Modify IoFactory's fs_mkdir, and add fs_renameAlex Crichton-1/+2
The invocation for making a directory should be able to specify a mode to make the directory with (instead of defaulting to one particular mode). Additionally, libuv and various OSes implement efficient versions of renaming files, so this operation is exposed as an IoFactory call.
2013-10-30Make Writer::flush a no-op default methodAlex Crichton-1/+0
Closes #9126
2013-10-25Enhance timers to create portsAlex Crichton-1/+3
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-24Remove the 'callback_ms' function from EventLoopAlex Crichton-1/+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-1/+15
2013-10-24wrapping libuv signal for use in RustDo Nhat Minh-0/+6
descriptive names easier-to-use api reorganize and document
2013-10-24Move stdin to using libuv's pipes instead of a ttyAlex Crichton-0/+1
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-1/+2
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-9/+4
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-1/+0
2013-10-24Remove IoFactoryObject for ~IoFactoryAlex Crichton-6/+27
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-7/+6
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-26/+20
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-0/+11
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-2/+0
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-1/+3
This fills in the `hints` structure and exposes libuv's full functionality for doing dns lookups.
2013-10-24Implement io::net::unixAlex Crichton-1/+18
2013-10-23Removed Unnecessary comments and white spaces #4386reedlepee-1/+0
2013-10-23Making fields in std and extra : private #4386reedlepee-1/+2
2013-09-18Implement process bindings to libuvAlex Crichton-0/+19
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).
2013-09-17std: remove RtioStreamJeff Olson-5/+0
2013-09-16std: remove impl'd/commented-out fstat signaturesJeff Olson-1/+0
2013-09-16std: bind uv_fs_readdir(), flesh out DirectoryInfo and docs/cleanupJeff Olson-0/+2
2013-09-16std: adding file::{stat,mkdir,rmdir}, FileInfo and FileReader/FileWriterJeff Olson-0/+2
add ignores for win32 tests on previous file io stuff...
2013-09-16std/rt: in-progress file io workJeff Olson-1/+8
std: remove unneeded field from RequestData struct std: rt::uv::file - map us_fs_stat & start refactoring calls into FsRequest std: stubbing out stat calls from the top-down into uvio std: us_fs_* operations are now by-val self methods on FsRequest std: post-rebase cleanup std: add uv_fs_mkdir|rmdir + tests & minor test cleanup in rt::uv::file WORKING: fleshing out FileStat and FileInfo + tests std: reverting test files.. refactoring back and cleanup...
2013-09-05std::rt: Add get_host_addresses functionBrian Anderson-0/+1
This is a very simplistic method for host name resolution. It converts a host name to a vector of IP addresses. Should be enough to get started.
2013-06-23Split out starting a listener from accepting incoming connections.Eric Reed-0/+5
The Listener trait takes two type parameters, the type of connection and the type of Acceptor, and specifies only one method, listen, which consumes the listener and produces an Acceptor. The Acceptor trait takes one type parameter, the type of connection, and defines two methods. The accept() method waits for an incoming connection attempt and returns the result. The incoming() method creates an iterator over incoming connections and is a default method. Example: let listener = TcpListener.bind(addr); // Bind to a socket let acceptor = listener.listen(); // Start the listener for stream in acceptor.incoming() { // Process incoming connections forever (or until you break out of the loop) }
2013-08-29Revert "auto merge of #8645 : alexcrichton/rust/issue-6436-run-non-blocking, ↵Brian Anderson-19/+3
r=brson" This reverts commit b8d1fa399402c71331aefd634d710004e00b73a6, reversing changes made to f22b4b169854c8a4ba86c16ee43327d6bcf94562. Conflicts: mk/rt.mk src/libuv
2013-08-27Implement process bindings to libuvAlex Crichton-3/+19
Closes #6436
2013-08-22std: put FileMode/Access->whence-mask in uvio, open/unlink as fns in file::Jeff Olson-1/+2