Skip to content

Commit

Permalink
Blanket rename Core to Reactor
Browse files Browse the repository at this point in the history
This commit uses a script to rename `Core` to `Reactor` all at once, notably:

    find . -name '*.rs' | xargs sed -i 's/\bCore\b/Reactor/g'
  • Loading branch information
alexcrichton committed Dec 5, 2017
1 parent 4606279 commit 108e1a2
Show file tree
Hide file tree
Showing 27 changed files with 74 additions and 74 deletions.
4 changes: 2 additions & 2 deletions benches/latency.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use futures::sync::mpsc;
use futures::{Future, Poll, Sink, Stream};
use test::Bencher;
use tokio::net::UdpSocket;
use tokio::reactor::Core;
use tokio::reactor::Reactor;

/// UDP echo server
struct EchoServer {
Expand Down Expand Up @@ -59,7 +59,7 @@ fn udp_echo_latency(b: &mut Bencher) {
let (tx, rx) = oneshot::channel();

let child = thread::spawn(move || {
let mut l = Core::new().unwrap();
let mut l = Reactor::new().unwrap();
let handle = l.handle();

let socket = tokio::net::UdpSocket::bind(&any_addr, &handle).unwrap();
Expand Down
10 changes: 5 additions & 5 deletions benches/tcp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ pub extern crate test;

mod prelude {
pub use futures::*;
pub use tokio::reactor::Core;
pub use tokio::reactor::Reactor;
pub use tokio::net::{TcpListener, TcpStream};
pub use tokio_io::io::read_to_end;

Expand All @@ -29,7 +29,7 @@ mod connect_churn {
#[bench]
fn one_thread(b: &mut Bencher) {
let addr = "127.0.0.1:0".parse().unwrap();
let mut core = Core::new().unwrap();
let mut core = Reactor::new().unwrap();
let handle = core.handle();
let listener = TcpListener::bind(&addr, &handle).unwrap();
let addr = listener.local_addr().unwrap();
Expand Down Expand Up @@ -63,7 +63,7 @@ mod connect_churn {
// Spawn reactor thread
thread::spawn(move || {
// Create the core
let mut core = Core::new().unwrap();
let mut core = Reactor::new().unwrap();

// Reactor handles
let handle = core.handle();
Expand Down Expand Up @@ -209,7 +209,7 @@ mod transfer {

fn one_thread(b: &mut Bencher, read_size: usize, write_size: usize) {
let addr = "127.0.0.1:0".parse().unwrap();
let mut core = Core::new().unwrap();
let mut core = Reactor::new().unwrap();
let handle = core.handle();
let listener = TcpListener::bind(&addr, &handle).unwrap();
let addr = listener.local_addr().unwrap();
Expand Down Expand Up @@ -255,7 +255,7 @@ mod transfer {
// Spawn reactor thread
thread::spawn(move || {
// Create the core
let mut core = Core::new().unwrap();
let mut core = Reactor::new().unwrap();

// Reactor handles
let handle = core.handle();
Expand Down
4 changes: 2 additions & 2 deletions examples/chat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ use futures::future::Executor;
use futures::stream::{self, Stream};
use futures_cpupool::CpuPool;
use tokio::net::TcpListener;
use tokio::reactor::Core;
use tokio::reactor::Reactor;
use tokio_io::io;
use tokio_io::AsyncRead;

Expand All @@ -42,7 +42,7 @@ fn main() {
let addr = addr.parse().unwrap();

// Create the event loop and TCP listener we'll accept connections on.
let mut core = Core::new().unwrap();
let mut core = Reactor::new().unwrap();
let handle = core.handle();
let socket = TcpListener::bind(&addr, &handle).unwrap();
println!("Listening on: {}", addr);
Expand Down
4 changes: 2 additions & 2 deletions examples/compress.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ use futures::{Future, Stream, Poll};
use futures::future::Executor;
use futures_cpupool::CpuPool;
use tokio::net::{TcpListener, TcpStream};
use tokio::reactor::Core;
use tokio::reactor::Reactor;
use tokio_io::{AsyncRead, AsyncWrite};
use flate2::write::GzEncoder;

Expand All @@ -41,7 +41,7 @@ fn main() {
// reactor.
let addr = env::args().nth(1).unwrap_or("127.0.0.1:8080".to_string());
let addr = addr.parse::<SocketAddr>().unwrap();
let mut core = Core::new().unwrap();
let mut core = Reactor::new().unwrap();
let handle = core.handle();
let socket = TcpListener::bind(&addr, &handle).unwrap();
println!("Listening on: {}", addr);
Expand Down
4 changes: 2 additions & 2 deletions examples/connect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ use std::thread;
use futures::sync::mpsc;
use futures::{Sink, Future, Stream};
use futures_cpupool::CpuPool;
use tokio::reactor::Core;
use tokio::reactor::Reactor;

fn main() {
// Determine if we're going to run in TCP or UDP mode
Expand All @@ -48,7 +48,7 @@ fn main() {
let addr = addr.parse::<SocketAddr>().unwrap();

// Create the event loop and initiate the connection to the remote server
let mut core = Core::new().unwrap();
let mut core = Reactor::new().unwrap();
let handle = core.handle();

let pool = CpuPool::new(1);
Expand Down
4 changes: 2 additions & 2 deletions examples/echo-threads.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ use futures_cpupool::CpuPool;
use tokio_io::AsyncRead;
use tokio_io::io::copy;
use tokio::net::TcpStream;
use tokio::reactor::Core;
use tokio::reactor::Reactor;

fn main() {
// First argument, the address to bind
Expand Down Expand Up @@ -69,7 +69,7 @@ fn main() {
}

fn worker(rx: mpsc::UnboundedReceiver<net::TcpStream>) {
let mut core = Core::new().unwrap();
let mut core = Reactor::new().unwrap();
let handle = core.handle();

let pool = CpuPool::new(1);
Expand Down
4 changes: 2 additions & 2 deletions examples/echo-udp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use std::net::SocketAddr;

use futures::{Future, Poll};
use tokio::net::UdpSocket;
use tokio::reactor::Core;
use tokio::reactor::Reactor;

struct Server {
socket: UdpSocket,
Expand Down Expand Up @@ -56,7 +56,7 @@ fn main() {

// Create the event loop that will drive this server, and also bind the
// socket we'll be listening to.
let mut l = Core::new().unwrap();
let mut l = Reactor::new().unwrap();
let handle = l.handle();
let socket = UdpSocket::bind(&addr, &handle).unwrap();
println!("Listening on: {}", socket.local_addr().unwrap());
Expand Down
10 changes: 5 additions & 5 deletions examples/echo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ use futures_cpupool::CpuPool;
use tokio_io::AsyncRead;
use tokio_io::io::copy;
use tokio::net::TcpListener;
use tokio::reactor::Core;
use tokio::reactor::Reactor;

fn main() {
// Allow passing an address to listen on as the first argument of this
Expand All @@ -42,15 +42,15 @@ fn main() {
let addr = addr.parse::<SocketAddr>().unwrap();

// First up we'll create the event loop that's going to drive this server.
// This is done by creating an instance of the `Core` type, tokio-core's
// This is done by creating an instance of the `Reactor` type, tokio-core's
// event loop. Most functions in tokio-core return an `io::Result`, and
// `Core::new` is no exception. For this example, though, we're mostly just
// `Reactor::new` is no exception. For this example, though, we're mostly just
// ignoring errors, so we unwrap the return value.
//
// After the event loop is created we acquire a handle to it through the
// `handle` method. With this handle we'll then later be able to create I/O
// objects.
let mut core = Core::new().unwrap();
let mut core = Reactor::new().unwrap();
let handle = core.handle();

// Next up we create a TCP listener which will listen for incoming
Expand Down Expand Up @@ -126,7 +126,7 @@ fn main() {
});

// And finally now that we've define what our server is, we run it! We
// didn't actually do much I/O up to this point and this `Core::run` method
// didn't actually do much I/O up to this point and this `Reactor::run` method
// is responsible for driving the entire server to completion.
//
// The `run` method will return the result of the future that it's running,
Expand Down
4 changes: 2 additions & 2 deletions examples/hello.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ use std::env;
use std::net::SocketAddr;

use futures::stream::Stream;
use tokio::reactor::Core;
use tokio::reactor::Reactor;
use tokio::net::TcpListener;

fn main() {
env_logger::init().unwrap();
let addr = env::args().nth(1).unwrap_or("127.0.0.1:8080".to_string());
let addr = addr.parse::<SocketAddr>().unwrap();

let mut core = Core::new().unwrap();
let mut core = Reactor::new().unwrap();
let listener = TcpListener::bind(&addr, &core.handle()).unwrap();

let addr = listener.local_addr().unwrap();
Expand Down
4 changes: 2 additions & 2 deletions examples/proxy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ use futures::{Future, Poll};
use futures::future::Executor;
use futures_cpupool::CpuPool;
use tokio::net::{TcpListener, TcpStream};
use tokio::reactor::Core;
use tokio::reactor::Reactor;
use tokio_io::{AsyncRead, AsyncWrite};
use tokio_io::io::{copy, shutdown};

Expand All @@ -43,7 +43,7 @@ fn main() {
let server_addr = server_addr.parse::<SocketAddr>().unwrap();

// Create the event loop that will drive this server.
let mut l = Core::new().unwrap();
let mut l = Reactor::new().unwrap();
let handle = l.handle();

let pool = CpuPool::new(1);
Expand Down
4 changes: 2 additions & 2 deletions examples/sink.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ use futures::stream::{self, Stream};
use futures_cpupool::CpuPool;
use tokio_io::IoFuture;
use tokio::net::{TcpListener, TcpStream};
use tokio::reactor::Core;
use tokio::reactor::Reactor;

fn main() {
env_logger::init().unwrap();
Expand All @@ -40,7 +40,7 @@ fn main() {

let pool = CpuPool::new(1);

let mut core = Core::new().unwrap();
let mut core = Reactor::new().unwrap();
let handle = core.handle();
let socket = TcpListener::bind(&addr, &handle).unwrap();
println!("Listening on: {}", addr);
Expand Down
6 changes: 3 additions & 3 deletions examples/tinydb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ use futures::prelude::*;
use futures::future::Executor;
use futures_cpupool::CpuPool;
use tokio::net::TcpListener;
use tokio::reactor::Core;
use tokio::reactor::Reactor;
use tokio_io::AsyncRead;
use tokio_io::io::{lines, write_all};

Expand All @@ -80,11 +80,11 @@ enum Response {
}

fn main() {
// Parse the address we're going to run this server on, create a `Core`, and
// Parse the address we're going to run this server on, create a `Reactor`, and
// set up our TCP listener to accept connections.
let addr = env::args().nth(1).unwrap_or("127.0.0.1:8080".to_string());
let addr = addr.parse::<SocketAddr>().unwrap();
let mut core = Core::new().unwrap();
let mut core = Reactor::new().unwrap();
let handle = core.handle();
let listener = TcpListener::bind(&addr, &handle).expect("failed to bind");
println!("Listening on: {}", addr);
Expand Down
4 changes: 2 additions & 2 deletions examples/tinyhttp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ use futures_cpupool::CpuPool;
use http::{Request, Response, StatusCode};
use http::header::HeaderValue;
use tokio::net::TcpStream;
use tokio::reactor::Core;
use tokio::reactor::Reactor;
use tokio_io::codec::{Encoder, Decoder};
use tokio_io::{AsyncRead};

Expand Down Expand Up @@ -70,7 +70,7 @@ fn main() {
}

fn worker(rx: mpsc::UnboundedReceiver<net::TcpStream>) {
let mut core = Core::new().unwrap();
let mut core = Reactor::new().unwrap();
let handle = core.handle();

let pool = CpuPool::new(1);
Expand Down
4 changes: 2 additions & 2 deletions examples/udp-codec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use futures::{Future, Stream, Sink};
use futures::future::Executor;
use futures_cpupool::CpuPool;
use tokio::net::{UdpSocket, UdpCodec};
use tokio::reactor::Core;
use tokio::reactor::Reactor;

pub struct LineCodec;

Expand All @@ -39,7 +39,7 @@ impl UdpCodec for LineCodec {
fn main() {
drop(env_logger::init());

let mut core = Core::new().unwrap();
let mut core = Reactor::new().unwrap();
let handle = core.handle();

let pool = CpuPool::new(1);
Expand Down
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@
//! use tokio_io::AsyncRead;
//! use tokio_io::io::copy;
//! use tokio::net::TcpListener;
//! use tokio::reactor::Core;
//! use tokio::reactor::Reactor;
//!
//! fn main() {
//! // Create the event loop that will drive this server.
//! let mut core = Core::new().unwrap();
//! let mut core = Reactor::new().unwrap();
//! let handle = core.handle();
//!
//! let pool = CpuPool::new_num_cpus();
Expand Down
20 changes: 10 additions & 10 deletions src/reactor/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! The core reactor driving all I/O.
//!
//! This module contains the [`Core`] reactor type which is the event loop for
//! This module contains the [`Reactor`] reactor type which is the event loop for
//! all I/O happening in `tokio`. This core reactor (or event loop) is used to
//! drive I/O resources.
//!
Expand All @@ -12,11 +12,11 @@
//! Lastly [`PollEvented`] can be used to construct I/O objects that interact
//! with the event loop, e.g. [`TcpStream`] in the net module.
//!
//! [`Core`]: struct.Core.html
//! [`Reactor`]: struct.Reactor.html
//! [`Handle`]: struct.Handle.html
//! [`Remote`]: struct.Remote.html
//! [handle_method]: struct.Core.html#method.handle
//! [remote_method]: struct.Core.html#method.remote
//! [handle_method]: struct.Reactor.html#method.handle
//! [remote_method]: struct.Reactor.html#method.remote
//! [`PollEvented`]: struct.PollEvented.html
//! [`TcpStream`]: ../net/struct.TcpStream.html

Expand Down Expand Up @@ -44,7 +44,7 @@ pub use self::poll_evented::PollEvented;
/// all other I/O events and notifications happening. Each event loop can have
/// multiple handles pointing to it, each of which can then be used to create
/// various I/O objects to interact with the event loop in interesting ways.
pub struct Core {
pub struct Reactor {
/// Reuse the `mio::Events` value across calls to poll.
events: mio::Events,

Expand Down Expand Up @@ -96,10 +96,10 @@ fn _assert_kinds() {
_assert::<Handle>();
}

impl Core {
impl Reactor {
/// Creates a new event loop, returning any error that happened during the
/// creation.
pub fn new() -> io::Result<Core> {
pub fn new() -> io::Result<Reactor> {
// Create the I/O poller
let io = try!(mio::Poll::new());

Expand All @@ -111,7 +111,7 @@ impl Core {
mio::Ready::readable(),
mio::PollOpt::level()));

Ok(Core {
Ok(Reactor {
events: mio::Events::with_capacity(1024),
_future_registration: future_pair.0,
future_readiness: Arc::new(MySetReadiness(future_pair.1)),
Expand Down Expand Up @@ -225,9 +225,9 @@ impl Core {
}
}

impl fmt::Debug for Core {
impl fmt::Debug for Reactor {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "Core")
write!(f, "Reactor")
}
}

Expand Down
Loading

0 comments on commit 108e1a2

Please sign in to comment.