Have new_with_stack impls return io::Result.
This commit is contained in:
@@ -66,7 +66,7 @@ impl<'a, Resume, Yield, Return> Fiber<'a, Resume, Yield, Return> {
|
||||
func: impl FnOnce(Resume, &Suspend<Resume, Yield, Return>) -> Return + 'a,
|
||||
) -> io::Result<Fiber<'a, Resume, Yield, Return>> {
|
||||
Ok(Fiber {
|
||||
inner: imp::Fiber::new_with_stack(top_of_stack, func),
|
||||
inner: imp::Fiber::new_with_stack(top_of_stack, func)?,
|
||||
done: Cell::new(false),
|
||||
_phantom: PhantomData,
|
||||
})
|
||||
|
||||
@@ -75,7 +75,7 @@ impl Fiber {
|
||||
Ok(fiber)
|
||||
}
|
||||
|
||||
pub fn new_with_stack<F, A, B, C>(top_of_stack: *mut u8, func: F) -> Self
|
||||
pub fn new_with_stack<F, A, B, C>(top_of_stack: *mut u8, func: F) -> io::Result<Self>
|
||||
where
|
||||
F: FnOnce(A, &super::Suspend<A, B, C>) -> C,
|
||||
{
|
||||
@@ -86,7 +86,7 @@ impl Fiber {
|
||||
|
||||
fiber.init(func);
|
||||
|
||||
fiber
|
||||
Ok(fiber)
|
||||
}
|
||||
|
||||
fn init<F, A, B, C>(&self, func: F)
|
||||
|
||||
@@ -3,6 +3,7 @@ use std::cell::Cell;
|
||||
use std::io;
|
||||
use std::ptr;
|
||||
use winapi::shared::minwindef::*;
|
||||
use winapi::shared::winerror::ERROR_NOT_SUPPORTED;
|
||||
use winapi::um::fibersapi::*;
|
||||
use winapi::um::winbase::*;
|
||||
|
||||
@@ -66,12 +67,11 @@ impl Fiber {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn new_with_stack<F, A, B, C>(_top_of_stack: *mut u8, _func: F) -> Self
|
||||
pub fn new_with_stack<F, A, B, C>(_top_of_stack: *mut u8, _func: F) -> io::Result<Self>
|
||||
where
|
||||
F: FnOnce(A, &super::Suspend<A, B, C>) -> C,
|
||||
{
|
||||
// Windows fibers have no support for custom stacks
|
||||
unimplemented!()
|
||||
Err(io::Error::from_raw_os_error(ERROR_NOT_SUPPORTED as i32))
|
||||
}
|
||||
|
||||
pub(crate) fn resume<A, B, C>(&self, result: &Cell<RunResult<A, B, C>>) {
|
||||
|
||||
Reference in New Issue
Block a user