Skip to content

Commit

Permalink
Move spawn errors into executor.rs
Browse files Browse the repository at this point in the history
  • Loading branch information
MajorBreakfast committed Jun 26, 2018
1 parent c055fef commit b39ea1d
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 67 deletions.
48 changes: 47 additions & 1 deletion src/libcore/task/executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
reason = "futures in libcore are unstable",
issue = "50547")]

use super::{TaskObj, SpawnObjError, SpawnErrorKind};
use fmt;
use super::{TaskObj, LocalTaskObj};

/// A task executor.
///
Expand Down Expand Up @@ -42,3 +43,48 @@ pub trait Executor {
Ok(())
}
}

/// Provides the reason that an executor was unable to spawn.
pub struct SpawnErrorKind {
_hidden: (),
}

impl fmt::Debug for SpawnErrorKind {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.debug_tuple("SpawnErrorKind")
.field(&"shutdown")
.finish()
}
}

impl SpawnErrorKind {
/// Spawning is failing because the executor has been shut down.
pub fn shutdown() -> SpawnErrorKind {
SpawnErrorKind { _hidden: () }
}

/// Check whether this error is the `shutdown` error.
pub fn is_shutdown(&self) -> bool {
true
}
}

/// The result of a failed spawn
#[derive(Debug)]
pub struct SpawnObjError {
/// The kind of error
pub kind: SpawnErrorKind,

/// The task for which spawning was attempted
pub task: TaskObj,
}

/// The result of a failed spawn
#[derive(Debug)]
pub struct SpawnLocalObjError {
/// The kind of error
pub kind: SpawnErrorKind,

/// The task for which spawning was attempted
pub task: LocalTaskObj,
}
7 changes: 3 additions & 4 deletions src/libcore/task/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,13 @@ mod context;
pub use self::context::Context;

mod executor;
pub use self::executor::Executor;
pub use self::executor::{
Executor, SpawnErrorKind, SpawnObjError, SpawnLocalObjError
};

mod poll;
pub use self::poll::Poll;

mod spawn_error;
pub use self::spawn_error::{SpawnErrorKind, SpawnObjError, SpawnLocalObjError};

mod task;
pub use self::task::{TaskObj, LocalTaskObj, UnsafeTask};

Expand Down
62 changes: 0 additions & 62 deletions src/libcore/task/spawn_error.rs

This file was deleted.

0 comments on commit b39ea1d

Please sign in to comment.