-
Notifications
You must be signed in to change notification settings - Fork 12.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
More scheduler and I/O work #5409
Closed
Closed
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
e8ddef9
core: Cleanup rt::context
brson d30c758
Give core::rt and std::net their own uvll bindings
brson 723d224
core: Don't use printf in rtdebug!
brson 54bb722
core: Simplify uvll bindings and strip out currently-unused bits
brson 42cba98
core: Convert some multiline statements to single-line
brson 9a075f2
core: Rename rt::io to rt::rtio
brson 5e6dacf
mk: If NO_REBUILD is set then don't rebuild core/std before testing
brson 57e85b5
core: Add rt::io and start sketching the API
brson 7ef54c7
core: Begin uv file system bindings
brson a882554
core: Refactor uv bindings
brson 0447034
Add a way to run the test suite with the new scheduler
brson 5af5766
core: Initialize global state lazily in the Scheduler ctor
brson 30d4124
Merge remote-tracking branch 'brson/rt'
brson File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT | ||
// file at the top-level directory of this distribution and at | ||
// http://rust-lang.org/COPYRIGHT. | ||
// | ||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or | ||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license | ||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your | ||
// option. This file may not be copied, modified, or distributed | ||
// except according to those terms. | ||
|
||
use prelude::*; | ||
use super::super::sched::*; | ||
use super::super::rtio::*; | ||
use super::Stream; | ||
|
||
pub struct FileStream; | ||
|
||
pub impl FileStream { | ||
fn new(_path: Path) -> FileStream { | ||
fail!() | ||
} | ||
} | ||
|
||
impl Stream for FileStream { | ||
fn read(&mut self, _buf: &mut [u8]) -> uint { | ||
fail!() | ||
} | ||
|
||
fn eof(&mut self) -> bool { | ||
fail!() | ||
} | ||
|
||
fn write(&mut self, _v: &const [u8]) { | ||
fail!() | ||
} | ||
} | ||
|
||
#[test] | ||
#[ignore] | ||
fn super_simple_smoke_test_lets_go_read_some_files_and_have_a_good_time() { | ||
let message = "it's alright. have a good time"; | ||
let filename = Path("test.txt"); | ||
let mut outstream = FileStream::new(filename); | ||
outstream.write(message.to_bytes()); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT | ||
// file at the top-level directory of this distribution and at | ||
// http://rust-lang.org/COPYRIGHT. | ||
// | ||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or | ||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license | ||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your | ||
// option. This file may not be copied, modified, or distributed | ||
// except according to those terms. | ||
|
||
use option::*; | ||
use comm::{GenericPort, GenericChan}; | ||
|
||
pub mod file; | ||
|
||
// FIXME #5370 Strongly want this to be StreamError(&mut Stream) | ||
pub struct StreamError; | ||
|
||
// XXX: Can't put doc comments on macros | ||
// Raised by `Stream` instances on error. Returning `true` from the handler | ||
// indicates that the `Stream` should continue, `false` that it should fail. | ||
condition! { | ||
stream_error: super::StreamError -> bool; | ||
} | ||
|
||
pub trait Stream { | ||
/// Read bytes, up to the length of `buf` and place them in `buf`, | ||
/// returning the number of bytes read or an `IoError`. Reads | ||
/// 0 bytes on EOF. | ||
/// | ||
/// # Failure | ||
/// | ||
/// Raises the `reader_error` condition on error | ||
fn read(&mut self, buf: &mut [u8]) -> uint; | ||
|
||
/// Return whether the Reader has reached the end of the stream | ||
fn eof(&mut self) -> bool; | ||
|
||
/// Write the given buffer | ||
/// | ||
/// # Failure | ||
/// | ||
/// Raises the `writer_error` condition on error | ||
fn write(&mut self, v: &const [u8]); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A note here, as I've seen a few conditions getting written this way lately: there's seldom a need to have a return value from a condition that tells the raise-site that it should fail; the handler itself can just fail (and indeed, untrapped conditions already fail). There's just as much context (more actually) visible to a backtrace if you let the handler / absence-of-handler itself fail.
Generally the only things that should show up in the return slot of a condition are data to use for recovery-and-continuation: sentinel values or replacement values, things that represent the handler saying "oh, well, use this value instead". If no such data is required or plausible (i.e. if the only reasonable thing one might do to recover is "ignore the error") then just put
()
in the return slot. If control proceeds past thecondition.raise()
line, you know a caller trapped the error and wants you to ignore it and continue.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see. I'll make this not return a bool.