Skip to content
Snippets Groups Projects
Commit 94aaca4e authored by Tsoj Tsoj's avatar Tsoj Tsoj
Browse files

Removed stupid comments

parent 47c0c639
No related merge requests found
......@@ -22,21 +22,20 @@ extern "C" fn context_function<ReturnValue>(t: Transfer) -> ! {
((*generator_ptr).f)(&mut (*generator_ptr));
}
loop {
compiler_fence(Ordering::AcqRel);
unsafe {
(*generator_ptr).is_finished = true;
(*generator_ptr).t = Some(
(*generator_ptr)
.t
.take()
.unwrap()
.context
.resume(generator_ptr as usize),
);
}
compiler_fence(Ordering::AcqRel);
compiler_fence(Ordering::AcqRel);
unsafe {
(*generator_ptr).is_finished = true;
(*generator_ptr).t = Some(
(*generator_ptr)
.t
.take()
.unwrap()
.context
.resume(generator_ptr as usize),
);
}
compiler_fence(Ordering::AcqRel);
panic!("We should be finished by now ...")
}
impl<ReturnValue> Generator<ReturnValue> {
......@@ -65,20 +64,10 @@ impl<ReturnValue> Generator<ReturnValue> {
}
}
// Implement `Iterator` for `Fibonacci`.
// The `Iterator` trait only requires a method to be defined for the `next` element.
impl<ReturnValue> Iterator for Generator<ReturnValue> {
// We can refer to this type using Self::Item
type Item = ReturnValue;
// Here, we define the sequence using `.curr` and `.next`.
// The return type is `Option<T>`:
// * When the `Iterator` is finished, `None` is returned.
// * Otherwise, the next value is wrapped in `Some` and returned.
// We use Self::Item in the return type, so we can change
// the type without having to update the function signatures.
fn next(&mut self) -> Option<Self::Item> {
// Allocate a Context on the stack.
let generator_ptr = self as *mut Generator<ReturnValue>;
unsafe {
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment