rustdoc: Convert to pipes

This commit is contained in:
Brian Anderson 2013-02-01 18:19:57 -08:00
parent 90f00a1c37
commit 5633783f47
4 changed files with 12 additions and 14 deletions

View File

@ -23,7 +23,6 @@ use parse;
use util;
use core::pipes::{stream, Chan, SharedChan, Port};
use core::oldcomm;
use core::vec;
use core::ops::Drop;
use rustc::back::link;

View File

@ -35,16 +35,17 @@ use trim_pass;
use unindent_pass;
use core::iter;
use core::oldcomm;
use core::str;
use core::vec;
use std::par;
use std::cell::Cell;
use syntax;
pub fn mk_pass(writer_factory: WriterFactory) -> Pass {
let writer_factory = Cell(writer_factory);
let f = fn~(move writer_factory,
srv: astsrv::Srv, doc: doc::Doc) -> doc::Doc {
run(srv, doc, copy writer_factory)
run(srv, doc, writer_factory.take())
};
Pass {
@ -155,7 +156,7 @@ fn should_request_new_writer_for_each_page() {
write_markdown(doc, move writer_factory);
// We expect two pages to have been written
for iter::repeat(2) {
oldcomm::recv(po);
po.recv();
}
}
@ -186,7 +187,7 @@ fn should_write_title_for_each_page() {
let doc = (page_pass::mk_pass(config::DocPerMod).f)(srv, doc);
write_markdown(doc, move writer_factory);
for iter::repeat(2) {
let (page, markdown) = oldcomm::recv(po);
let (page, markdown) = po.recv();
match page {
doc::CratePage(_) => {
assert str::contains(markdown, ~"% Crate core");
@ -848,7 +849,6 @@ mod test {
use tystr_pass;
use unindent_pass;
use core::oldcomm;
use core::path::Path;
use core::str;
@ -900,7 +900,7 @@ mod test {
) -> ~str {
let (writer_factory, po) = markdown_writer::future_writer_factory();
write_markdown(doc, move writer_factory);
return oldcomm::recv(po).second();
return po.recv().second();
}
pub fn write_markdown_str_srv(
@ -910,7 +910,7 @@ mod test {
let (writer_factory, po) = markdown_writer::future_writer_factory();
let pass = mk_pass(move writer_factory);
(pass.f)(srv, doc);
return oldcomm::recv(po).second();
return po.recv().second();
}
#[test]

View File

@ -19,7 +19,6 @@ use pass::Pass;
use core::io::ReaderUtil;
use core::io;
use core::libc;
use core::oldcomm;
use core::os;
use core::pipes;
use core::result;
@ -293,16 +292,17 @@ fn write_file(path: &Path, s: ~str) {
}
pub fn future_writer_factory(
) -> (WriterFactory, oldcomm::Port<(doc::Page, ~str)>) {
let markdown_po = oldcomm::Port();
let markdown_ch = oldcomm::Chan(&markdown_po);
) -> (WriterFactory, Port<(doc::Page, ~str)>) {
let (markdown_po, markdown_ch) = stream();
let markdown_ch = SharedChan(markdown_ch);
let writer_factory = fn~(page: doc::Page) -> Writer {
let (writer_po, writer_ch) = pipes::stream();
let markdown_ch = markdown_ch.clone();
do task::spawn |move writer_ch| {
let (writer, future) = future_writer();
writer_ch.send(move writer);
let s = future.get();
oldcomm::send(markdown_ch, (copy page, s));
markdown_ch.send((copy page, s));
}
writer_po.recv()
};

View File

@ -10,7 +10,6 @@
use core::prelude::*;
use core::oldcomm;
use core::task;
// Just a named container for our op, so it can have impls