|
12 | 12 | reason = "futures in libcore are unstable",
|
13 | 13 | issue = "50547")]
|
14 | 14 |
|
15 |
| -use super::{TaskObj, SpawnObjError, SpawnErrorKind}; |
| 15 | +use fmt; |
| 16 | +use super::{TaskObj, LocalTaskObj}; |
16 | 17 |
|
17 | 18 | /// A task executor.
|
18 | 19 | ///
|
@@ -42,3 +43,48 @@ pub trait Executor {
|
42 | 43 | Ok(())
|
43 | 44 | }
|
44 | 45 | }
|
| 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 | +} |
0 commit comments