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