authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2018-07-30 13:07:04-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2018-07-30 13:07:04-04:00
logcfe03c764de0d2edfbad74a71d7c18f0fd68b506
tree0aa391152b43f52e3095a22fb09caaa2d39be3c9
parentc91c781952bd9750c029a48d0dd7a5a24ec089cf

fix docs for break from suspend


1 files changed, 6 insertions(+), 6 deletions(-)

doc/langref.html.in+6-6
......@@ -4665,24 +4665,24 @@ async fn testSuspendBlock() void {
46654665 block, while the old thread continued executing the suspend block.
46664666 </p>
46674667 <p>
4668 However, if you use labeled <code>break</code> on the suspend block, the coroutine
4668 However, the coroutine can be directly resumed from the suspend block, in which case it
46694669 never returns to its resumer and continues executing.
46704670 </p>
46714671 {#code_begin|test#}
46724672const std = @import("std");
46734673const assert = std.debug.assert;
46744674
4675test "break from suspend" {
4675test "resume from suspend" {
46764676 var buf: [500]u8 = undefined;
46774677 var a = &std.heap.FixedBufferAllocator.init(buf[0..]).allocator;
46784678 var my_result: i32 = 1;
4679 const p = try async<a> testBreakFromSuspend(&my_result);
4679 const p = try async<a> testResumeFromSuspend(&my_result);
46804680 cancel p;
46814681 std.debug.assert(my_result == 2);
46824682}
4683async fn testBreakFromSuspend(my_result: *i32) void {
4684 s: suspend |p| {
4685 break :s;
4683async fn testResumeFromSuspend(my_result: *i32) void {
4684 suspend |p| {
4685 resume p;
46864686 }
46874687 my_result.* += 1;
46884688 suspend;