Why does the closed status of channel need a uint32?

95 views
Skip to first unread message

Paul Zhang

unread,
Mar 27, 2021, 11:18:27 AM3/27/21
to golang-nuts
For the channel structure:

type hchan struct {
    qcount   uint
    dataqsiz uint
    buf      unsafe.Pointer
    elemsize uint16
    closed   uint32
    elemtype *_type
    sendx    uint
    recvx    uint
    recvq    waitq
    sendq    waitq

    lock mutex
}

Why does the closed need a uint32? I am reading the code and found that it seems to be only 0 or 1.

Axel Wagner

unread,
Mar 27, 2021, 11:21:02 AM3/27/21
to Paul Zhang, golang-nuts
Because there are no atomic operations for smaller integers, I assume :)

--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/be0dcd41-2819-4636-8ab6-125d0e9ee07bn%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages