| ... | @@ -337,8 +337,6 @@ const AsyncClosure = struct { | ... | @@ -337,8 +337,6 @@ const AsyncClosure = struct { |
| 337 | select_condition: ?*ResetEvent, | 337 | select_condition: ?*ResetEvent, |
| 338 | context_alignment: std.mem.Alignment, | 338 | context_alignment: std.mem.Alignment, |
| 339 | result_offset: usize, | 339 | result_offset: usize, |
| 340 | /// Whether the task has a return type with nonzero bits. | | |
| 341 | has_result: bool, | | |
| 342 | | 340 | |
| 343 | const done_reset_event: *ResetEvent = @ptrFromInt(@alignOf(ResetEvent)); | 341 | const done_reset_event: *ResetEvent = @ptrFromInt(@alignOf(ResetEvent)); |
| 344 | | 342 | |
| ... | @@ -348,12 +346,8 @@ const AsyncClosure = struct { | ... | @@ -348,12 +346,8 @@ const AsyncClosure = struct { |
| 348 | if (@cmpxchgStrong(std.Thread.Id, &closure.cancel_tid, 0, tid, .acq_rel, .acquire)) |cancel_tid| { | 346 | if (@cmpxchgStrong(std.Thread.Id, &closure.cancel_tid, 0, tid, .acq_rel, .acquire)) |cancel_tid| { |
| 349 | assert(cancel_tid == Closure.canceling_tid); | 347 | assert(cancel_tid == Closure.canceling_tid); |
| 350 | // Even though we already know the task is canceled, we must still | 348 | // Even though we already know the task is canceled, we must still |
| 351 | // run the closure in order to make the return value valid - that | 349 | // run the closure in order to make the return value valid and in |
| 352 | // is, unless the result is zero bytes! | 350 | // case there are side effects. |
| 353 | if (!ac.has_result) { | | |
| 354 | ac.reset_event.set(); | | |
| 355 | return; | | |
| 356 | } | | |
| 357 | } | 351 | } |
| 358 | current_closure = closure; | 352 | current_closure = closure; |
| 359 | ac.func(ac.contextPointer(), ac.resultPointer()); | 353 | ac.func(ac.contextPointer(), ac.resultPointer()); |
| ... | @@ -389,7 +383,6 @@ const AsyncClosure = struct { | ... | @@ -389,7 +383,6 @@ const AsyncClosure = struct { |
| 389 | } | 383 | } |
| 390 | | 384 | |
| 391 | fn free(ac: *AsyncClosure, gpa: Allocator, result_len: usize) void { | 385 | fn free(ac: *AsyncClosure, gpa: Allocator, result_len: usize) void { |
| 392 | if (!ac.has_result) assert(result_len == 0); | | |
| 393 | const base: [*]align(@alignOf(AsyncClosure)) u8 = @ptrCast(ac); | 386 | const base: [*]align(@alignOf(AsyncClosure)) u8 = @ptrCast(ac); |
| 394 | gpa.free(base[0 .. ac.result_offset + result_len]); | 387 | gpa.free(base[0 .. ac.result_offset + result_len]); |
| 395 | } | 388 | } |
| ... | @@ -432,7 +425,6 @@ fn async( | ... | @@ -432,7 +425,6 @@ fn async( |
| 432 | .func = start, | 425 | .func = start, |
| 433 | .context_alignment = context_alignment, | 426 | .context_alignment = context_alignment, |
| 434 | .result_offset = result_offset, | 427 | .result_offset = result_offset, |
| 435 | .has_result = result.len != 0, | | |
| 436 | .reset_event = .unset, | 428 | .reset_event = .unset, |
| 437 | .select_condition = null, | 429 | .select_condition = null, |
| 438 | }; | 430 | }; |
| ... | @@ -503,7 +495,6 @@ fn concurrent( | ... | @@ -503,7 +495,6 @@ fn concurrent( |
| 503 | .func = start, | 495 | .func = start, |
| 504 | .context_alignment = context_alignment, | 496 | .context_alignment = context_alignment, |
| 505 | .result_offset = result_offset, | 497 | .result_offset = result_offset, |
| 506 | .has_result = result_len != 0, | | |
| 507 | .reset_event = .unset, | 498 | .reset_event = .unset, |
| 508 | .select_condition = null, | 499 | .select_condition = null, |
| 509 | }; | 500 | }; |