Skip to content

Commit b39ea1d

Browse files
Move spawn errors into executor.rs
1 parent c055fef commit b39ea1d

File tree

3 files changed

+50
-67
lines changed

3 files changed

+50
-67
lines changed

src/libcore/task/executor.rs

+47-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
reason = "futures in libcore are unstable",
1313
issue = "50547")]
1414

15-
use super::{TaskObj, SpawnObjError, SpawnErrorKind};
15+
use fmt;
16+
use super::{TaskObj, LocalTaskObj};
1617

1718
/// A task executor.
1819
///
@@ -42,3 +43,48 @@ pub trait Executor {
4243
Ok(())
4344
}
4445
}
46+
47+
/// Provides the reason that an executor was unable to spawn.
48+
pub struct SpawnErrorKind {
49+
_hidden: (),
50+
}
51+
52+
impl fmt::Debug for SpawnErrorKind {
53+
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
54+
f.debug_tuple("SpawnErrorKind")
55+
.field(&"shutdown")
56+
.finish()
57+
}
58+
}
59+
60+
impl SpawnErrorKind {
61+
/// Spawning is failing because the executor has been shut down.
62+
pub fn shutdown() -> SpawnErrorKind {
63+
SpawnErrorKind { _hidden: () }
64+
}
65+
66+
/// Check whether this error is the `shutdown` error.
67+
pub fn is_shutdown(&self) -> bool {
68+
true
69+
}
70+
}
71+
72+
/// The result of a failed spawn
73+
#[derive(Debug)]
74+
pub struct SpawnObjError {
75+
/// The kind of error
76+
pub kind: SpawnErrorKind,
77+
78+
/// The task for which spawning was attempted
79+
pub task: TaskObj,
80+
}
81+
82+
/// The result of a failed spawn
83+
#[derive(Debug)]
84+
pub struct SpawnLocalObjError {
85+
/// The kind of error
86+
pub kind: SpawnErrorKind,
87+
88+
/// The task for which spawning was attempted
89+
pub task: LocalTaskObj,
90+
}

src/libcore/task/mod.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,13 @@ mod context;
1818
pub use self::context::Context;
1919

2020
mod executor;
21-
pub use self::executor::Executor;
21+
pub use self::executor::{
22+
Executor, SpawnErrorKind, SpawnObjError, SpawnLocalObjError
23+
};
2224

2325
mod poll;
2426
pub use self::poll::Poll;
2527

26-
mod spawn_error;
27-
pub use self::spawn_error::{SpawnErrorKind, SpawnObjError, SpawnLocalObjError};
28-
2928
mod task;
3029
pub use self::task::{TaskObj, LocalTaskObj, UnsafeTask};
3130

src/libcore/task/spawn_error.rs

-62
This file was deleted.

0 commit comments

Comments
 (0)