On Fri, Aug 17, 2018 at 3:28 AM, <xiaoxub...@gmail.com> wrote: > > I am new to golang source code, and recently met a problem about > understanding golang gc. > > In runtime/mgcwork.go: 114 > > func (w *gcWork) put(obj uintptr) { > flushed := false > wbuf := w.wbuf1 > if wbuf == nil { > w.init() > wbuf = w.wbuf1 > // wbuf is empty at this point. > } else if wbuf.nobj == len(wbuf.obj) { // why is this the condition that > wbuf is full? > ... > } > > > > > I don't understand why wbuf.nobj == len(wbuf.obj) is the condition that wbuf > is full. Any help makes sense to me.
If you look at the definition of the workbuf type, you will see that the obj field is an array. The nobj field counts the number of elements that have been put in the array. When nobj is the length of the array, there is no room for any more elements. Ian -- 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+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.