about summary refs log tree commit diff
path: root/src/librustuv/timer.rs
AgeCommit message (Collapse)AuthorLines
2014-10-01Remove librustuvAaron Turon-173/+0
This commit removes the `librustuv` crate. See the [runtime removal RFC](https://github.com/rust-lang/rfcs/pull/230) for more context. See [green-rs](https://github.com/alexcrichton/green-rs/) for a possible migration path if you wish to continue using green-threaded I/O. The library provides its own I/O API surface. [breaking-change]
2014-08-28Fallout from stabilizing core::optionAaron Turon-2/+2
2014-07-03Fix spelling errors.Joseph Crail-1/+1
2014-06-28Rename all raw pointers as necessaryAlex Crichton-4/+4
2014-06-15Register new snapshotsAlex Crichton-4/+4
2014-06-06rustuv: Deal with the rtio changesAlex Crichton-161/+11
2014-05-07rustuv: Implement timeouts for unix networkingAlex Crichton-1/+1
This commit implements the set{,_read,_write}_timeout() methods for the libuv-based networking I/O objects. The implementation details are commented thoroughly throughout the implementation.
2014-05-06librustc: Remove `~EXPR`, `~TYPE`, and `~PAT` from the language, exceptPatrick Walton-1/+1
for `~str`/`~[]`. Note that `~self` still remains, since I forgot to add support for `Box<self>` before the snapshot. How to update your code: * Instead of `~EXPR`, you should write `box EXPR`. * Instead of `~TYPE`, you should write `Box<Type>`. * Instead of `~PATTERN`, you should write `box PATTERN`. [breaking-change]
2014-05-02Replace most ~exprs with 'box'. #11779Brian Anderson-1/+1
2014-04-24Update libuvAlex Crichton-3/+1
This update brings a few months of changes, but primarily a fix for the following situation. When creating a handle to stdin, libuv used to set the stdin handle to nonblocking mode. This would end up affect this stdin handle across all processes that shared it, which mean that stdin become nonblocking for everyone using the same stdin. On linux, this also affected *stdout* because stdin/stdout roughly point at the same thing. This problem became apparent when running the test suite manually on a local computer. The stdtest suite (running with libgreen) would set stdout to nonblocking mode (as described above), and then the next test suite would always fail for a printing failure (because stdout was returning EAGAIN). This has been fixed upstream, joyent/libuv@342e8c, and this update pulls in this fix. This also brings us in line with a recently upstreamed libuv patch. Closes #13336 Closes #13355
2014-04-23std: Add support for an accept() timeoutAlex Crichton-8/+11
This adds experimental support for timeouts when accepting sockets through `TcpAcceptor::accept`. This does not add a separate `accept_timeout` function, but rather it adds a `set_timeout` function instead. This second function is intended to be used as a hard deadline after which all accepts will never block and fail immediately. This idea was derived from Go's SetDeadline() methods. We do not currently have a robust time abstraction in the standard library, so I opted to have the argument be a relative time in millseconds into the future. I believe a more appropriate argument type is an absolute time, but this concept does not exist yet (this is also why the function is marked #[experimental]). The native support is built on select(), similarly to connect_timeout(), and the green support is based on channel select and a timer. cc #13523
2014-04-19std: Add an experimental connect_timeout functionAlex Crichton-6/+10
This adds a `TcpStream::connect_timeout` function in order to assist opening connections with a timeout (cc #13523). There isn't really much design space for this specific operation (unlike timing out normal blocking reads/writes), so I am fairly confident that this is the correct interface for this function. The function is marked #[experimental] because it takes a u64 timeout argument, and the u64 type is likely to change in the future.
2014-04-10std: Make std::comm return types consistentAlex Crichton-6/+6
There are currently a number of return values from the std::comm methods, not all of which are necessarily completely expressive: Sender::try_send(t: T) -> bool This method currently doesn't transmit back the data `t` if the send fails due to the other end having disconnected. Additionally, this shares the name of the synchronous try_send method, but it differs in semantics in that it only has one failure case, not two (the buffer can never be full). SyncSender::try_send(t: T) -> TrySendResult<T> This method accurately conveys all possible information, but it uses a custom type to the std::comm module with no convenience methods on it. Additionally, if you want to inspect the result you're forced to import something from `std::comm`. SyncSender::send_opt(t: T) -> Option<T> This method uses Some(T) as an "error value" and None as a "success value", but almost all other uses of Option<T> have Some/None the other way Receiver::try_recv(t: T) -> TryRecvResult<T> Similarly to the synchronous try_send, this custom return type is lacking in terms of usability (no convenience methods). With this number of drawbacks in mind, I believed it was time to re-work the return types of these methods. The new API for the comm module is: Sender::send(t: T) -> () Sender::send_opt(t: T) -> Result<(), T> SyncSender::send(t: T) -> () SyncSender::send_opt(t: T) -> Result<(), T> SyncSender::try_send(t: T) -> Result<(), TrySendError<T>> Receiver::recv() -> T Receiver::recv_opt() -> Result<T, ()> Receiver::try_recv() -> Result<T, TryRecvError> The notable changes made are: * Sender::try_send => Sender::send_opt. This renaming brings the semantics in line with the SyncSender::send_opt method. An asychronous send only has one failure case, unlike the synchronous try_send method which has two failure cases (full/disconnected). * Sender::send_opt returns the data back to the caller if the send is guaranteed to fail. This method previously returned `bool`, but then it was unable to retrieve the data if the data was guaranteed to fail to send. There is still a race such that when `Ok(())` is returned the data could still fail to be received, but that's inherent to an asynchronous channel. * Result is now the basis of all return values. This not only adds lots of convenience methods to all return values for free, but it also means that you can inspect the return values with no extra imports (Ok/Err are in the prelude). Additionally, it's now self documenting when something failed or not because the return value has "Err" in the name. Things I'm a little uneasy about: * The methods send_opt and recv_opt are not returning options, but rather results. I felt more strongly that Option was the wrong return type than the _opt prefix was wrong, and I coudn't think of a much better name for these methods. One possible way to think about them is to read the _opt suffix as "optionally". * Result<T, ()> is often better expressed as Option<T>. This is only applicable to the recv_opt() method, but I thought it would be more consistent for everything to return Result rather than one method returning an Option. Despite my two reasons to feel uneasy, I feel much better about the consistency in return values at this point, and I think the only real open question is if there's a better suffix for {send,recv}_opt. Closes #11527
2014-04-04Fix fallout from std::libc separationCorey Richardson-1/+1
2014-03-13std: Rename Chan/Port types and constructorAlex Crichton-10/+10
* Chan<T> => Sender<T> * Port<T> => Receiver<T> * Chan::new() => channel() * constructor returns (Sender, Receiver) instead of (Receiver, Sender) * local variables named `port` renamed to `rx` * local variables named `chan` renamed to `tx` Closes #11765
2014-02-12Expose whether event loops have active I/OAlex Crichton-13/+13
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-11Move replace and swap to std::mem. Get rid of std::utilEdward Wang-4/+4
Also move Void to std::any, move drop to std::mem and reexport in prelude.
2014-02-03std: Remove try_send_deferred plus all falloutAlex Crichton-1/+1
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-03rustuv: Require all results are used and fix falloutAlex Crichton-9/+9
2014-01-29Remove do keyword from librustuvScott Lawrence-6/+6
2013-12-25Test fixes and rebase conflictsAlex Crichton-1/+1
* 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-24std: Remove must deferred sending functionsAlex Crichton-2/+2
These functions are all unnecessary now, and they only have meaning in the M:N context. Removing these functions uncovered a bug in the librustuv timer bindings, but it was fairly easy to cover (and the test is already committed). These cannot be completely removed just yet due to their usage in the WaitQueue of extra::sync, and until the mutex in libextra is rewritten it will not be possible to remove the deferred sends for channels.
2013-12-24green: Fixing all tests from previous refactoringsAlex Crichton-3/+3
2013-12-24rustuv: Get all tests passing again after refactorAlex Crichton-0/+1
All tests except for the homing tests are now working again with the librustuv/libgreen refactoring. The homing-related tests are currently commented out and now placed in the rustuv::homing module. I plan on refactoring scheduler pool spawning in order to enable more homing tests in a future commit.
2013-12-24rustuv: Reimplement without using std::rt::schedAlex Crichton-14/+13
This reimplements librustuv without using the interfaces provided by the scheduler in libstd. This solely uses the new Runtime trait in order to interface with the local task and perform the necessary scheduling operations. The largest snag in this refactoring is reimplementing homing. The new runtime trait exposes no concept of "homing" a task or forcibly sending a task to a remote scheduler (there is no concept of a scheduler). In order to reimplement homing, the transferrence of tasks is now done at the librustuv level instead of the scheduler level. This means that all I/O loops now have a concurrent queue which receives homing messages and requests. This allows the entire implementation of librustuv to be only dependent on the runtime trait, severing all dependence of librustuv on the scheduler and related green-thread functions. This is all in preparation of the introduction of libgreen and libnative. At the same time, I also took the liberty of removing all glob imports from librustuv.
2013-12-16Test fallout from std::comm rewriteAlex Crichton-13/+29
2013-12-16Fallout of rewriting std::commAlex Crichton-5/+4
2013-12-10libextra: Another round of de-`Cell`-ing.Patrick Walton-7/+6
34 uses of `Cell` remain.
2013-12-03Move std::util::ignore to std::prelude::dropSteven Fackler-2/+2
It's a more fitting name for the most common use case of this function.
2013-11-26librustuv: Remove all non-`proc` uses of `do` from `libextra` andPatrick Walton-2/+2
`librustuv`.
2013-11-10Fix usage of libuv for windowsAlex Crichton-3/+30
2013-11-10Carefully destroy channels at the right time.Alex Crichton-9/+41
When a channel is destroyed, it may attempt scheduler operations which could move a task off of it's I/O scheduler. This is obviously a bad interaction, and some finesse is required to make it work (making destructors run at the right time). Closes #10375
2013-11-10Another round of test fixes from previous commitsAlex Crichton-2/+76
2013-11-10Make the uv bindings resilient to linked failureAlex Crichton-32/+29
In the ideal world, uv I/O could be canceled safely at any time. In reality, however, we are unable to do this. Right now linked failure is fairly flaky as implemented in the runtime, making it very difficult to test whether the linked failure mechanisms inside of the uv bindings are ready for this kind of interaction. Right now, all constructors will execute in a task::unkillable block, and all homing I/O operations will prevent linked failure in the duration of the homing operation. What this means is that tasks which perform I/O are still susceptible to linked failure, but the I/O operations themselves will never get interrupted. Instead, the linked failure will be received at the edge of the I/O operation.
2013-11-10Assorted test fixes and merge conflictsAlex Crichton-4/+4
2013-11-10Update all uv tests to pass againAlex Crichton-75/+35
2013-11-10Clean up the remaining chunks of uvAlex Crichton-2/+2
2013-11-10Migrate uv net bindings away from ~fn()Alex Crichton-5/+2
2013-11-10Migrate uv file bindings away from ~fn()Alex Crichton-3/+3
2013-11-10Fixing rebase conflicts and suchAlex Crichton-22/+18
This cleans up the merging of removing ~fn() and removing C++ wrappers to a compile-able and progress-ready state
2013-11-10Migrate uv signal handling away from ~fn()Alex Crichton-2/+1
2013-11-10Migrate uv process bindings away from ~fn()Alex Crichton-3/+3
2013-11-10Migrate uv timer bindings away from ~fn()Alex Crichton-33/+98
2013-11-10uv: Remove lots of uv/C++ wrappersAlex Crichton-3/+3
2013-10-29Move rust's uv implementation to its own crateAlex Crichton-0/+157
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