Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DotPathPile ¶
type DotPathPile struct {
// contains filtered or unexported fields
}
DotPathPile is a hybrid container for a lazily and concurrently populated growing-only slice of items (of type `*dotpath.DotPath`) which may be traversed in parallel to it's growth.
Usage for a pile `p`:
p := MakeDotPathPile(128, 32)
Have it grow concurrently using multiple:
var item *dotpath.DotPath = something p.Pile(item)
in as many go routines as You may seem fit.
In parallel, You may either traverse `p` in parallel right away:
for item, ok := p.Iter(); ok; item, ok = p.Next() { ... do sth with item ... }
Here p.Iter() starts a new transversal with the first item (if any), and p.Next() keeps traverses the DotPathPile.
or traverse blocking / awaiting close first:
for item := range <-p.Done() { ... do sth with item ... }
or use the result when available:
r, p := <-p.Done(), nil
Hint: here we get the result in `r` and at the same time discard / deallocate / forget the pile `p` itself.
Note: The traversal is *not* intended to be concurrency safe! Thus: You may call `Pile` concurrently to Your traversal, but use of either `Done` or `Iter` and `Next` *must* be confined to a single go routine (thread).
func MakeDotPathPile ¶
func MakeDotPathPile(size, buff int) *DotPathPile
MakeDotPathPile returns a (pointer to a) fresh pile of items (of type `*dotpath.DotPath`) with size as initial capacity and with buff as initial leeway, allowing as many Pile's to execute non-blocking before respective Done or Next's.
func (*DotPathPile) Close ¶
func (d *DotPathPile) Close() (err error)
Close - call once when everything has been piled.
Close intentionally implements io.Closer ¶
Note: After Close(), any Close(...) will panic and any Pile(...) will panic and any Done() or Next() will return immediately: no eventual blocking, that is.
func (*DotPathPile) Done ¶
func (d *DotPathPile) Done() (done <-chan []*dotpath.DotPath)
Done returns a channel which emits the result (as slice of DotPath) once the pile is closed.
Users of Done() *must not* iterate (via Iter() Next()...) before the done-channel is closed!
Done is a convenience - useful iff You do not like/need to start any traversal before the pile is fully populated. Once the pile is closed, Done() will signal in constant time.
Note: Upon signalling, the pile is reset to it's tip, so You may traverse it (via Next) right away. Usage for a pile `p`: Traverse blocking / awaiting close first:
for item := range <-p.Done() { ... do sth with item ... }
or use the result when available
r, p := <-p.Done(), nil
while discaring the pile itself.
func (*DotPathPile) Iter ¶
func (d *DotPathPile) Iter() (item *dotpath.DotPath, ok bool)
Iter puts the pile iterator back to the beginning and returns the first `Next()`, iff any. Usage for a pile `p`:
for item, ok := p.Iter(); ok; item, ok = p.Next() { ... do sth with item ... }
func (*DotPathPile) Next ¶
func (d *DotPathPile) Next() (item *dotpath.DotPath, ok bool)
Next returns the next item, or false iff the pile is exhausted.
Note: Iff the pile is not closed yet, Next may block, awaiting some Pile().
func (*DotPathPile) Pile ¶
func (d *DotPathPile) Pile(item *dotpath.DotPath)
Pile appends an `*dotpath.DotPath` item to the DotPathPile.
Note: Pile will block iff buff is exceeded and no Done() or Next()'s are used.