Comment fixes from Emmanuel
This commit is contained in:
parent
0f8ebd024d
commit
e47ce81422
|
@ -18,7 +18,7 @@ import (
|
||||||
/*
|
/*
|
||||||
|
|
||||||
CElement is an element of a linked-list
|
CElement is an element of a linked-list
|
||||||
Traversal from a CElement are goroutine-safe.
|
Traversal from a CElement is goroutine-safe.
|
||||||
|
|
||||||
We can't avoid using WaitGroups or for-loops given the documentation
|
We can't avoid using WaitGroups or for-loops given the documentation
|
||||||
spec without re-implementing the primitives that already exist in
|
spec without re-implementing the primitives that already exist in
|
||||||
|
@ -220,6 +220,7 @@ func (l *CList) Front() *CElement {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *CList) FrontWait() *CElement {
|
func (l *CList) FrontWait() *CElement {
|
||||||
|
// Loop until the head is non-nil else wait and try again
|
||||||
for {
|
for {
|
||||||
l.mtx.RLock()
|
l.mtx.RLock()
|
||||||
head := l.head
|
head := l.head
|
||||||
|
@ -230,8 +231,7 @@ func (l *CList) FrontWait() *CElement {
|
||||||
return head
|
return head
|
||||||
}
|
}
|
||||||
wg.Wait()
|
wg.Wait()
|
||||||
// l.head doesn't necessarily exist here.
|
// NOTE: If you think l.head exists here, think harder.
|
||||||
// That's why we need to continue a for-loop.
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue