const Status = packed struct(usize) tag: enum(u2) { /// The future is queued or running (depending on whether `thread` is set). pending = 0b00, /// Like `pending`, but the future is being awaited. `Future.awaiter` is populated. pending_awaited = 0b01, /// Like `pending`, but the future is being canceled. `Future.awaiter` is populated. pending_canceled = 0b11, /// The future has already completed. `thread` is `.null`, unless the future terminated /// with an acknowledged cancel request, in which case `thread` is `.all_ones`. done = 0b10, }The values of this enum are chosen so that await/cancel can just OR with 0b01 and 0b11 respectively. That does clobber .done, but that's actually fine, because if the tag is .done then only the awaiter is referencing this Future anyway.
thread: Thread.PackedPtrWhen the future begins execution, this is atomically updated from null to the thread running the Future, so that cancelation knows which thread to cancel.
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661 const Status = packed struct(usize) {
/// The values of this enum are chosen so that await/cancel can just OR with 0b01 and 0b11
/// respectively. That *does* clobber `.done`, but that's actually fine, because if the tag
/// is `.done` then only the awaiter is referencing this `Future` anyway.
tag: enum(u2) {
/// The future is queued or running (depending on whether `thread` is set).
pending = 0b00,
/// Like `pending`, but the future is being awaited. `Future.awaiter` is populated.
pending_awaited = 0b01,
/// Like `pending`, but the future is being canceled. `Future.awaiter` is populated.
pending_canceled = 0b11,
/// The future has already completed. `thread` is `.null`, unless the future terminated
/// with an acknowledged cancel request, in which case `thread` is `.all_ones`.
done = 0b10,
},
/// When the future begins execution, this is atomically updated from `null` to the thread running the
/// `Future`, so that cancelation knows which thread to cancel.
thread: Thread.PackedPtr,
}