about summary refs log tree commit diff
path: root/src/libstd/rt
AgeCommit message (Collapse)AuthorLines
2013-10-28std: Move the SendDeferred trait to std::commBrian Anderson-7/+1
2013-10-28auto merge of #10133 : alexcrichton/rust/another-error, r=thestingerbors-1/+2
This cropped up on the bsd bot, and if it's an error that gets thrown then it's fine to just whitelist another type of error in the test.
2013-10-28Register new snapshotsAlex Crichton-110/+83
2013-10-28Make some more rt components publicAlex Crichton-23/+15
Primarily this makes the Scheduler and all of its related interfaces public. The reason for doing this is that currently any extern event loops had no access to the scheduler at all. This allows third-party event loops to manipulate the scheduler, along with allowing the uv event loop to live inside of its own crate.
2013-10-28add support for the `cold` function attributeDaniel Micay-0/+1
This allows a function to marked as infrequently called, resulting in any branch calling it to be considered colder.
2013-10-28Handle another possible error in a unix pipe testAlex Crichton-1/+2
This cropped up on the bsd bot, and if it's an error that gets thrown then it's fine to just whitelist another type of error in the test.
2013-10-28Remove the extension traits for Readers/WritersAlex Crichton-606/+487
These methods are all excellent candidates for default methods, so there's no need to require extra imports of various traits.
2013-10-28auto merge of #10094 : alexcrichton/rust/issue-8704, r=pcwaltonbors-65/+248
This drops more of the old C++ runtime to rather be written in rust. A few features were lost along the way, but hopefully not too many. The main loss is that there are no longer backtraces associated with allocations (rust doesn't have a way of acquiring those just yet). Other than that though, I believe that the rest of the debugging utilities made their way over into rust. Closes #8704
2013-10-28auto merge of #10093 : alexcrichton/rust/issue-8811, r=pcwaltonbors-6/+15
Closes #8811
2013-10-28auto merge of #10083 : alexcrichton/rust/timer-port, r=pcwaltonbors-6/+170
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-100/+192
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-27auto merge of #10080 : brson/rust/sched_queue, r=brsonbors-105/+444
Rebase and update of #9710
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-26Fix a typo in a rt::io::signal testAlex Crichton-1/+1
It was pretty much a miracle that these tests were ever passing. They would never have passed in the single threaded case because only one sigint in the tests is ever generated, but when run in parallel two sigints will be generated.
2013-10-26Implement another error code found on windows.Alex Crichton-6/+15
Closes #8811
2013-10-26Rewrite boxed_region/memory_region in RustAlex Crichton-65/+248
This drops more of the old C++ runtime to rather be written in rust. A few features were lost along the way, but hopefully not too many. The main loss is that there are no longer backtraces associated with allocations (rust doesn't have a way of acquiring those just yet). Other than that though, I believe that the rest of the debugging utilities made their way over into rust. Closes #8704
2013-10-26auto merge of #10070 : alexcrichton/rust/fewer-missiles, r=brsonbors-36/+49
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-6/+170
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-25Encapsulate the lock-free mpsc queue in the MessageQueue typeBrian Anderson-57/+15
2013-10-25Add links to original mpmc and mpsc implementationsBrian Anderson-0/+3
2013-10-25TidyBrian Anderson-6/+6
2013-10-25minorJason Toffaletti-2/+6
2013-10-25minorJason Toffaletti-2/+2
2013-10-25fix bug introduced by previous clean up. more clean up.Jason Toffaletti-23/+19
2013-10-25clean upJason Toffaletti-36/+38
2013-10-25add padding to prevent false sharingJason Toffaletti-0/+8
2013-10-25add multi-producer multi-consumer bounded queue to use for sleeper listJason Toffaletti-56/+211
2013-10-25add cache line paddingJason Toffaletti-4/+11
2013-10-25lock-free queue for scheduler message queueJason Toffaletti-4/+210
2013-10-25Fire fewer homing missilesAlex Crichton-36/+49
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-30/+138
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-30/+138
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-24Implement a basic event loop built on LittleLockAlex Crichton-14/+316
It's not guaranteed that there will always be an event loop to run, and this implementation will serve as an incredibly basic one which does not provide any I/O, but allows the scheduler to still run. cc #9128
2013-10-24Remove the 'callback_ms' function from EventLoopAlex Crichton-20/+3
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-24Fix a bug with the scheduler and destructor orderAlex Crichton-1/+11
The PausibleIdleCallback must have some handle into the event loop, and because struct destructors are run in order of top-to-bottom in order of fields, this meant that the event loop was getting destroyed before the idle callback was getting destroyed. I can't confirm that this fixes a problem in how we use libuv, but it does semantically fix a problem for usage with other event loops.
2013-10-24Another round of test fixes and merge conflictsAlex Crichton-139/+222
2013-10-24Bring io::signal up to date with changes to rt::rtioAlex Crichton-79/+75
2013-10-24wrapping libuv signal for use in RustDo Nhat Minh-0/+374
descriptive names easier-to-use api reorganize and document
2013-10-24Fixing some tests, adding some pipesAlex Crichton-1/+33
This adds constructors to pipe streams in the new runtime to take ownership of file descriptors, and also fixes a few tests relating to the std::run changes (new errors are raised on io_error and one test is xfail'd).
2013-10-24Migrate std::run to libuv processesAlex Crichton-7/+6
2013-10-24Remove std::io once and for all!Alex Crichton-1/+82
2013-10-24Remove std::io from ebmlAlex Crichton-24/+62
2013-10-24Test fixes and merge conflictsAlex Crichton-54/+92
2013-10-24Move stdin to using libuv's pipes instead of a ttyAlex Crichton-84/+48
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-24Remove io::read_errorAlex Crichton-44/+38
The general idea is to remove conditions completely from I/O, so in the meantime remove the read_error condition to mean the same thing as the io_error condition.
2013-10-24Stop logging task failure to task loggersAlex Crichton-9/+11
The isn't an ideal patch, and the comment why is in the code. Basically uvio uses task::unkillable which touches the kill flag for a task, and if the task is failing due to mismangement of the kill flag, then there will be serious problems when the task tries to print that it's failing.
2013-10-24Move as much I/O as possible off of native::ioAlex Crichton-99/+159
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-19/+14
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-45/+47
2013-10-24Remove IoFactoryObject for ~IoFactoryAlex Crichton-313/+300
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.