Skip to content

Commit 2ea55d7

Browse files
authored
Merge pull request #25998 from ziglang/std.Io.Threaded-async-guarantee
std.Io: guarantee when async() returns, task is already completed or has been successfully assigned a unit of concurrency
2 parents d828115 + 7096e66 commit 2ea55d7

File tree

5 files changed

+139
-118
lines changed

5 files changed

+139
-118
lines changed

lib/std/Io.zig

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -580,6 +580,9 @@ pub const VTable = struct {
580580
/// If it returns `null` it means `result` has been already populated and
581581
/// `await` will be a no-op.
582582
///
583+
/// When this function returns non-null, the implementation guarantees that
584+
/// a unit of concurrency has been assigned to the returned task.
585+
///
583586
/// Thread-safe.
584587
async: *const fn (
585588
/// Corresponds to `Io.userdata`.
@@ -1024,6 +1027,10 @@ pub const Group = struct {
10241027
///
10251028
/// `function` *may* be called immediately, before `async` returns.
10261029
///
1030+
/// When this function returns, it is guaranteed that `function` has
1031+
/// already been called and completed, or it has successfully been assigned
1032+
/// a unit of concurrency.
1033+
///
10271034
/// After this is called, `wait` or `cancel` must be called before the
10281035
/// group is deinitialized.
10291036
///
@@ -1094,6 +1101,10 @@ pub fn Select(comptime U: type) type {
10941101
///
10951102
/// `function` *may* be called immediately, before `async` returns.
10961103
///
1104+
/// When this function returns, it is guaranteed that `function` has
1105+
/// already been called and completed, or it has successfully been
1106+
/// assigned a unit of concurrency.
1107+
///
10971108
/// After this is called, `wait` or `cancel` must be called before the
10981109
/// select is deinitialized.
10991110
///
@@ -1524,8 +1535,11 @@ pub fn Queue(Elem: type) type {
15241535
/// not guaranteed to be available until `await` is called.
15251536
///
15261537
/// `function` *may* be called immediately, before `async` returns. This has
1527-
/// weaker guarantees than `concurrent`, making more portable and
1528-
/// reusable.
1538+
/// weaker guarantees than `concurrent`, making more portable and reusable.
1539+
///
1540+
/// When this function returns, it is guaranteed that `function` has already
1541+
/// been called and completed, or it has successfully been assigned a unit of
1542+
/// concurrency.
15291543
///
15301544
/// See also:
15311545
/// * `Group`

0 commit comments

Comments
 (0)